當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilder.selectColumns方法代碼示例

本文整理匯總了Java中com.j256.ormlite.stmt.QueryBuilder.selectColumns方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.selectColumns方法的具體用法?Java QueryBuilder.selectColumns怎麽用?Java QueryBuilder.selectColumns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.j256.ormlite.stmt.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.selectColumns方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lookupTagsForEBook

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<Tag> lookupTagsForEBook(EBook ebk) throws SQLException {
    if (tagsForEBookQuery == null) {
        QueryBuilder<EBookTags, Long> dbQryBld = dbHelper.getEBookTagsDao().queryBuilder();

        // this time selecting for the user-id field
        dbQryBld.selectColumns(EBookTags.COLUMN_NAME_TAG_ID);
        SelectArg postSelectArg = new SelectArg();
        dbQryBld.where().eq(EBookTags.COLUMN_NAME_BOOK_ID, postSelectArg);

        // build our outer query
        QueryBuilder<Tag, Long> userQb = dbHelper.getTagDao().queryBuilder();
        // where the user-id matches the inner query's user-id field
        userQb.where().in(Tag.COLUMN_NAME_ID, dbQryBld);
        tagsForEBookQuery = userQb.prepare();
    }
    tagsForEBookQuery.setArgumentHolderValue(0, ebk);
    return dbHelper.getTagDao().query(tagsForEBookQuery);
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:19,代碼來源:LibraryManager.java

示例2: lookupEBooksForTag

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<EBook> lookupEBooksForTag(Tag pTag) throws SQLException {
    if (ebooksForTagQuery == null) {
        // build our inner query for UserPost objects
        QueryBuilder<EBookTags, Long> dbQryBld = dbHelper.getEBookTagsDao().queryBuilder();

        // just select the post-id field
        dbQryBld.selectColumns(EBookTags.COLUMN_NAME_BOOK_ID);
        SelectArg userSelectArg = new SelectArg();

        dbQryBld.where().eq(EBookTags.COLUMN_NAME_TAG_ID, userSelectArg);

        // build our outer query for Post objects
        QueryBuilder<EBook, Long> postQb = dbHelper.getEBookDao().queryBuilder()
                .orderByRaw("book_title COLLATE NOCASE");
        // where the id matches in the post-id from the inner query
        postQb.where().in(EBook.COLUMN_NAME_ID, dbQryBld);
        ebooksForTagQuery = postQb.prepare();
    }
    if (pTag != null) {
        ebooksForTagQuery.setArgumentHolderValue(0, pTag);
        return dbHelper.getEBookDao().query(ebooksForTagQuery);
    }
    return new ArrayList<>();
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:25,代碼來源:LibraryManager.java

示例3: lookupEBooksForFileType

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<EBook> lookupEBooksForFileType(FileType pTag) throws SQLException {
    if (ebooksForFiletypeQuery == null) {
        // build our inner query for UserPost objects
        QueryBuilder<EBookFileTypes, Long> dbQryBld = dbHelper.getEBookFileTypesDao().queryBuilder();

        // just select the post-id field
        dbQryBld.selectColumns(EBookFileTypes.COLUMN_NAME_BOOK_ID);
        SelectArg userSelectArg = new SelectArg();

        dbQryBld.where().eq(EBookFileTypes.COLUMN_NAME_TYPE_ID, userSelectArg);

        // build our outer query for Post objects
        QueryBuilder<EBook, Long> postQb = dbHelper.getEBookDao().queryBuilder();
        // where the id matches in the post-id from the inner query
        postQb.where().in(EBook.COLUMN_NAME_ID, dbQryBld);
        ebooksForFiletypeQuery = postQb.prepare();
    }
    if (pTag != null) {
        ebooksForFiletypeQuery.setArgumentHolderValue(0, pTag);
        return dbHelper.getEBookDao().query(ebooksForFiletypeQuery);
    }
    return new ArrayList<>();
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:24,代碼來源:LibraryManager.java

示例4: lookupFileTypesForEBook

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<FileType> lookupFileTypesForEBook(EBook ebk) throws SQLException {
    if (filetypeForEBookQuery == null) {
        QueryBuilder<EBookFileTypes, Long> dbQryBld = dbHelper.getEBookFileTypesDao().queryBuilder();

        // this time selecting for the user-id field
        dbQryBld.selectColumns(EBookFileTypes.COLUMN_NAME_TYPE_ID);
        SelectArg postSelectArg = new SelectArg();
        dbQryBld.where().eq(EBookFileTypes.COLUMN_NAME_BOOK_ID, postSelectArg);

        // build our outer query
        QueryBuilder<FileType, Long> userQb = dbHelper.getFileTypeDao().queryBuilder();
        // where the user-id matches the inner query's user-id field
        userQb.where().in(FileType.COLUMN_NAME_ID, dbQryBld);
        filetypeForEBookQuery = userQb.prepare();
    }
    filetypeForEBookQuery.setArgumentHolderValue(0, ebk);
    return dbHelper.getFileTypeDao().query(filetypeForEBookQuery);
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:19,代碼來源:LibraryManager.java

示例5: lookupEBooksForAuthor

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<EBook> lookupEBooksForAuthor(Author pTag) throws SQLException {
    if (ebooksForFiletypeQuery == null) {
        // build our inner query for UserPost objects
        QueryBuilder<EBookAuthors, Long> dbQryBld = dbHelper.getEBookAuthorsDao().queryBuilder();

        // just select the post-id field
        dbQryBld.selectColumns(EBookAuthors.COLUMN_NAME_BOOK_ID);
        SelectArg userSelectArg = new SelectArg();

        dbQryBld.where().eq(EBookAuthors.COLUMN_NAME_AUTHOR_ID, userSelectArg);

        // build our outer query for Post objects
        QueryBuilder<EBook, Long> postQb = dbHelper.getEBookDao().queryBuilder();
        // where the id matches in the post-id from the inner query
        postQb.where().in(EBook.COLUMN_NAME_ID, dbQryBld);
        ebooksForFiletypeQuery = postQb.prepare();
    }
    if (pTag != null) {
        ebooksForFiletypeQuery.setArgumentHolderValue(0, pTag);
        return dbHelper.getEBookDao().query(ebooksForFiletypeQuery);
    }
    return new ArrayList<>();
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:24,代碼來源:LibraryManager.java

示例6: lookupAuthorsForEBook

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
private List<Author> lookupAuthorsForEBook(EBook ebk) throws SQLException {
    if (authorForEBookQuery == null) {
        QueryBuilder<EBookAuthors, Long> dbQryBld = dbHelper.getEBookAuthorsDao().queryBuilder();

        // this time selecting for the user-id field
        dbQryBld.selectColumns(EBookAuthors.COLUMN_NAME_AUTHOR_ID);
        SelectArg postSelectArg = new SelectArg();
        dbQryBld.where().eq(EBookAuthors.COLUMN_NAME_BOOK_ID, postSelectArg);

        // build our outer query
        QueryBuilder<Author, Long> userQb = dbHelper.getAuthorDao().queryBuilder();
        // where the user-id matches the inner query's user-id field
        userQb.where().in(Author.COLUMN_NAME_ID, dbQryBld);
        authorForEBookQuery = userQb.prepare();
    }
    authorForEBookQuery.setArgumentHolderValue(0, ebk);
    return dbHelper.getAuthorDao().query(authorForEBookQuery);
}
 
開發者ID:mrspaceman,項目名稱:ebookmgr,代碼行數:19,代碼來源:LibraryManager.java

示例7: queryAllBySelectColumns

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
/**
 * 返回數據庫中所有記錄的指定列的值
 *
 * @param selectColumns 指定列名
 * @return
 */
public List<T> queryAllBySelectColumns(String[] selectColumns) {
    List<T> list = null;
    QueryBuilder queryBuilder = ormLiteDao.queryBuilder();
    try {
        queryBuilder.selectColumns(selectColumns);
        list = queryBuilder.query();
    } catch (SQLException e) {
        LogUtils.e(e);
    }
    return list;
}
 
開發者ID:lujianzhao,項目名稱:AndroidBase,代碼行數:18,代碼來源:OrmLiteDao.java

示例8: getQueryIdsForOrg

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
protected void getQueryIdsForOrg(MitroRequestContext context, int orgId, Set<Integer> userIds, Set<Integer> secretIds, Set<Integer> groupIds)
    throws MitroServletException, SQLException {
  // TODO: We need to create an API for orgs and clean this up.
  @SuppressWarnings("deprecation")
  AuthenticatedDB userDb = AuthenticatedDB.deprecatedNew(context.manager, context.requestor);
  if (!userDb.isOrganizationAdmin(orgId)) {
    throw new MitroServletException("Not org or no access");
  }

  RPC.GetOrganizationStateResponse out = GetOrganizationState.doOperation(context,  orgId);

  userIds.clear();

  // TODO: change GetOrganizationState query to return the user id column.
  if (!out.members.isEmpty()) {
    QueryBuilder<DBIdentity, Integer> query = context.manager.identityDao.queryBuilder();
    query.selectColumns(DBIdentity.ID_NAME);
    Where<DBIdentity, Integer> where = query.where();
    where.in(DBIdentity.NAME_FIELD_NAME, Manager.makeSelectArgsFromList(out.members));

    for (DBIdentity identity : query.query()) {
      userIds.add(identity.getId());
    }
  }

  secretIds.clear();
  secretIds.addAll(out.orgSecretsToPath.keySet());
  secretIds.addAll(out.orphanedSecretsToPath.keySet());

  groupIds.clear();
  groupIds.addAll(out.groups.keySet());
}
 
開發者ID:WeAreWizards,項目名稱:passopolis-server,代碼行數:33,代碼來源:GetAuditLog.java

示例9: getRoles

import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
public List<Role> getRoles() throws SQLException {
	QueryBuilder<UserRole, Integer> userRoleQb = 
			ConfigLoader.getInstance().getUserRoles().queryBuilder();
	userRoleQb.selectColumns(UserRole.ROLE_ID_FIELD_NAME);
	
	userRoleQb.where().eq(UserRole.USER_ID_FIELD_NAME, this.login_name);
	
	QueryBuilder<Role, String> roleQb = ConfigLoader.getInstance().getRoles().queryBuilder();
	
	roleQb.where().in(Role.ROLE_NAME_COLUMN, userRoleQb);
	
	List<Role> roles = ConfigLoader.getInstance().getRoles().query(roleQb.prepare());
	
	if (roles == null)
		return new ArrayList<Role>();
	
	return roles;
}
 
開發者ID:sinnlabs,項目名稱:dbvim,代碼行數:19,代碼來源:User.java


注:本文中的com.j256.ormlite.stmt.QueryBuilder.selectColumns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。