本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder.query方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder.query方法的具体用法?Java QueryBuilder.query怎么用?Java QueryBuilder.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.stmt.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFocusList
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 返回完整Focus List
*
* @param module
* @return
*/
public List<FocusItemInfo> getFocusList()
{
List<FocusItemInfo> koItemInfoList = null;
try
{
QueryBuilder<FocusItemInfo, Long> queryBuilder = mFocusItemInfoDao.queryBuilder();
// queryBuilder.groupBy("category");
queryBuilder.orderBy("order_by", true);
koItemInfoList = queryBuilder.query();
}
catch (SQLException e)
{
e.printStackTrace();
}
return koItemInfoList;
}
示例2: getLatest
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<MerchantService> getLatest(Long limit, Long offset) throws IOException {
try {
QueryBuilder<MerchantService, String> queryBuilder = dao.queryBuilder();
queryBuilder.orderBy(MerchantService.PURCHASE_DATE_FIELD_NAME, false);
queryBuilder.limit(limit);
queryBuilder.offset(offset);
List<MerchantService> results = queryBuilder.query();
refresh(results);
return results;
} catch (Exception e) {
throw new IOException(e);
}
}
示例3: getByTagSync
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
private static List<Long> getByTagSync(final long tagId) {
final RuntimeExceptionDao<MyTagPhoto, Long> daoTagPhoto = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTagPhoto.class);
try {
QueryBuilder<MyTagPhoto, Long> tagPhotoQb = daoTagPhoto.queryBuilder();
tagPhotoQb.where().eq("tagId", tagId);
List<MyTagPhoto> tagPhotos = tagPhotoQb.query();
List<Long> photoIds = new ArrayList<>();
for (MyTagPhoto tp : tagPhotos) {
photoIds.add(tp.photoId);
}
return photoIds;
} catch (Exception e) {
Log.w(TAG, e.getMessage());
return null;
}
}
示例4: getLatest
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Customer> getLatest(Long limit, Long offset) throws IOException {
try {
QueryBuilder<Customer, String> queryBuilder = dao.queryBuilder();
queryBuilder.orderBy(Customer.CREATIONDATE_FIELD_NAME, false);
queryBuilder.limit(limit);
queryBuilder.offset(offset);
List<Customer> results = queryBuilder.query();
refresh(results);
return results;
} catch (Exception e) {
throw new IOException(e);
}
}
示例5: getAll
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* This method do not return deleted resources
*
* @param type
* @return
* @throws IOException
*/
public List<Accommodation> getAll(Type type) throws IOException {
if (type == null) {
throw new NullPointerException("Type is null");
}
try {
QueryBuilder builder = dao.queryBuilder();
builder.where().eq(Accommodation.TYPE_FIELD_NAME, type);
builder.where().eq(Accommodation.DELETED_FIELD_NAME, false);
return builder.query();
} catch (SQLException e) {
throw new IOException(e);
}
}
示例6: getByAccommodationId
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Reservation> getByAccommodationId(Long accommodationId, long limit, long offset, boolean orderAscending) throws IOException {
try {
QueryBuilder queryBuilder = dao.queryBuilder();
queryBuilder.where().eq(Reservation.ACCOMMODATION_FIELD_NAME, accommodationId);
queryBuilder.orderBy(Reservation.DATEBEGIN_FIELD_NAME, orderAscending);
queryBuilder.limit(limit);
queryBuilder.offset(offset);
List results = queryBuilder.query();
refresh(results);
return results;
} catch (SQLException e) {
throw new IOException(e);
}
}
示例7: getScoreListOrderByDate
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 排行榜, 按时间排序
*
* @param offset
* @param count
* @return
*/
public List<GameRanking> getScoreListOrderByDate(long offset, long count)
{
QueryBuilder<GameRanking, ?> qb = getDao().queryBuilder();
try
{
// qb.where().eq("user_name", userName);
qb.offset(offset);
qb.limit(count);
qb.orderBy("record_date", false);
return qb.query();
}
catch (SQLException e)
{
e.printStackTrace();
}
return null;
}
示例8: queryGeByOrder
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 排序查询指定条件下,大于指定值的所有记录
*
* @param orderColumn 大于的列
* @param limitValue 大于的值
* @param columnName 查询条件列名
* @param value 查询条件值
* @param ascending true为升序,false为降序
* @return
*/
public List<T> queryGeByOrder(String orderColumn, Object limitValue, String columnName, Object value, boolean ascending) {
List<T> list = null;
QueryBuilder queryBuilder = ormLiteDao.queryBuilder();
Where where = queryBuilder.where();
try {
where.eq(columnName, value);
where.and().ge(orderColumn, limitValue);
queryBuilder.orderBy(orderColumn, ascending);
list = queryBuilder.query();
} catch (SQLException e) {
LogUtils.e(e);
}
return list;
}
示例9: queryForPagesByOrder
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 分页查询,并按列排序
*
* @param orderColumn 排序列名
* @param ascending true为升序,false为降序
* @param offset 搜索下标
* @param count 搜索条数
* @return 分页查询后的数据集
*/
public List<T> queryForPagesByOrder(String orderColumn, boolean ascending, Long offset, Long count) {
List<T> list = null;
QueryBuilder queryBuilder = ormLiteDao.queryBuilder();
Where where = queryBuilder.where();
try {
where.isNotNull(orderColumn);
queryBuilder.orderBy(orderColumn, ascending);
queryBuilder.offset(offset);
queryBuilder.limit(count);
list = queryBuilder.query();
} catch (SQLException e) {
LogUtils.e(e);
}
return list;
}
示例10: getScoreListOrderByScore
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 排行榜, 按积分排序
*
* @param offset
* @param count
* @return
*/
public List<GameRanking> getScoreListOrderByScore(long offset, long count)
{
QueryBuilder<GameRanking, ?> qb = getDao().queryBuilder();
try
{
// qb.where().eq("user_name", userName);
qb.offset(offset);
qb.limit(count);
qb.orderBy("score", true);
return qb.query();
}
catch (SQLException e)
{
e.printStackTrace();
}
return null;
}
示例11: onDataSetChanged
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Override
public void onDataSetChanged() {
Log.i("ZULIP_WIDGET", "onDataSetChanged() = Data reloaded");
QueryBuilder<Message, Object> queryBuilder = ZulipApp.get().getDao(Message.class).queryBuilder();
String filter;
filter = setupWhere();
if (!filter.equals("")) {
queryBuilder.where().raw(filter);
}
try {
messageList = queryBuilder.query();
} catch (SQLException e) {
ZLog.logException(e);
}
}
示例12: getDiaryTalks
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public static List<Talk> getDiaryTalks(Context context){
DataBaseHelper dataBaseHelper = OpenHelperManager.getHelper(context, DataBaseHelper.class);
try {
QueryBuilder<Talk, String> builder = dataBaseHelper.getTalkDao().queryBuilder();
builder.orderBy("order",true);
Where<Talk,String> where = builder.where();
where.eq("scheduled", true);
List<Talk> talkList = builder.query();
if(!talkList.isEmpty() && talkList!=null) {
return talkList;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
示例13: getPrivateOrgGroup
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
protected DBGroup getPrivateOrgGroup(DBGroup organization, DBIdentity member)
throws SQLException {
// get all of member's groups
QueryBuilder<DBAcl, Integer> directMemberQuery =
manager.aclDao.queryBuilder().selectColumns(DBAcl.GROUP_ID_FIELD_NAME);
directMemberQuery.where().eq(DBAcl.MEMBER_IDENTITY_FIELD_NAME, member.getId());
// from those groups, get the groups that are also part of organization
QueryBuilder<DBAcl, Integer> query = manager.aclDao.queryBuilder();
query.where().in(DBAcl.GROUP_ID_FIELD_NAME, directMemberQuery).and()
.eq(DBAcl.MEMBER_GROUP_FIELD_NAME, organization.getId());
// find the private group from the list organization groups this user belongs to
for (DBAcl acl : query.query()) {
DBGroup group = acl.loadGroup(manager.groupDao);
if (group.isPrivateUserGroup()) {
return group;
}
}
fail("did not find member's private organization group");
return null;
}
示例14: queryByExtension
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Query by extension name, table name, and column name
*
* @param extensionName
* extension name
* @param tableName
* table name
* @param columnName
* column name
* @return extensions
* @throws SQLException
*/
public Extensions queryByExtension(String extensionName, String tableName,
String columnName) throws SQLException {
QueryBuilder<Extensions, Void> qb = queryBuilder();
setUniqueWhere(qb.where(), extensionName, true, tableName, true,
columnName);
List<Extensions> extensions = qb.query();
Extensions extension = null;
if (extensions.size() > 1) {
throw new GeoPackageException("More than one "
+ Extensions.class.getSimpleName()
+ " existed for unique combination of Extension Name: "
+ extensionName + ", Table Name: " + tableName
+ ", Column Name: " + columnName);
} else if (extensions.size() == 1) {
extension = extensions.get(0);
}
return extension;
}
示例15: queryByUnique
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Query by the unique column values
*
* @param constraintName
* constraint name
* @param constraintType
* constraint type
* @param value
* value
* @return data column constraints
* @throws SQLException
*/
public DataColumnConstraints queryByUnique(String constraintName,
DataColumnConstraintType constraintType, String value)
throws SQLException {
DataColumnConstraints constraint = null;
QueryBuilder<DataColumnConstraints, Void> qb = queryBuilder();
setUniqueWhere(qb.where(), constraintName, constraintType, value);
List<DataColumnConstraints> constraints = qb.query();
if (!constraints.isEmpty()) {
if (constraints.size() > 1) {
throw new GeoPackageException("More than one "
+ DataColumnConstraints.class.getSimpleName()
+ " was found for unique constraint. Name: "
+ constraintName + ", Type: " + constraintType
+ ", Value: " + value);
}
constraint = constraints.get(0);
}
return constraint;
}