本文整理汇总了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);
}
示例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<>();
}
示例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<>();
}
示例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);
}
示例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<>();
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}