当前位置: 首页>>代码示例>>Java>>正文


Java QueryBuilder.limit方法代码示例

本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder.limit方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder.limit方法的具体用法?Java QueryBuilder.limit怎么用?Java QueryBuilder.limit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.stmt.QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.limit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAll

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Accommodation> getAll(Long limit, Long offset, boolean withDeletedEntities) throws IOException {

        // return all with deleted
        if (withDeletedEntities) {
            return super.getAll(limit, offset);
        }

        // return all but deleted
        else {
            try {
                QueryBuilder builder = dao.queryBuilder();
                if (limit != -1l) {
                    builder.limit(limit);
                }
                if (offset != -1l) {
                    builder.offset(offset);
                }
                builder.where().eq(Accommodation.DELETED_FIELD_NAME, false);
                return builder.query();
            } catch (SQLException e) {
                throw new IOException(e);
            }
        }
    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:25,代码来源:AccommodationService.java

示例2: 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);
        }

    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:19,代码来源:CustomerService.java

示例3: getAll

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<MerchantServiceType> getAll(Long limit, Long offset, boolean withDeletedEntities) throws IOException {

        // return all with deleted
        if (withDeletedEntities) {
            return super.getAll(limit, offset);
        }

        // return all but deleted
        else {
            try {
                QueryBuilder builder = dao.queryBuilder();
                if (limit != -1l) {
                    builder.limit(limit);
                }
                if (offset != -1l) {
                    builder.offset(offset);
                }
                builder.where().eq(MerchantServiceType.DELETED_FIELD_NAME, false);
                return builder.query();
            } catch (SQLException e) {
                throw new IOException(e);
            }
        }
    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:25,代码来源:MerchantServiceTypesService.java

示例4: 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);
        }

    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:19,代码来源:MerchantServiceService.java

示例5: 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);
        }
    }
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:18,代码来源:ReservationService.java

示例6: 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;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:26,代码来源:GameRankingBiz.java

示例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;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:27,代码来源:GameRankingBiz.java

示例8: 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;
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:25,代码来源:OrmLiteDao.java

示例9: lastBg

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Nullable
public static BgReading lastBg() {
    List<BgReading> bgList = null;

    try {
        Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
        QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
        queryBuilder.orderBy("date", false);
        queryBuilder.limit(1L);
        queryBuilder.where().gt("value", 38);
        PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
        bgList = daoBgReadings.query(preparedQuery);

    } catch (SQLException e) {
        log.debug(e.getMessage(), e);
    }
    if (bgList != null && bgList.size() > 0)
        return bgList.get(0);
    else
        return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:22,代码来源:DatabaseHelper.java

示例10: deleteDbRequestbyMongoId

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public int deleteDbRequestbyMongoId(String action, String id) {
    try {
        QueryBuilder<DbRequest, String> queryBuilder = getDaoDbRequest().queryBuilder();
        Where where = queryBuilder.where();
        where.eq("_id", id).and().eq("action", action);
        queryBuilder.limit(10L);
        PreparedQuery<DbRequest> preparedQuery = queryBuilder.prepare();
        List<DbRequest> dbList = getDaoDbRequest().query(preparedQuery);
        if (dbList.size() != 1) {
            log.error("deleteDbRequestbyMongoId query size: " + dbList.size());
        } else {
            //log.debug("Treatment findTreatmentById found: " + trList.get(0).log());
            return delete(dbList.get(0));
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return 0;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:20,代码来源:DatabaseHelper.java

示例11: findTreatmentById

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Nullable
public Treatment findTreatmentById(String _id) {
    try {
        Dao<Treatment, Long> daoTreatments = getDaoTreatments();
        QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
        Where where = queryBuilder.where();
        where.eq("_id", _id);
        queryBuilder.limit(10L);
        PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
        List<Treatment> trList = daoTreatments.query(preparedQuery);
        if (trList.size() != 1) {
            //log.debug("Treatment findTreatmentById query size: " + trList.size());
            return null;
        } else {
            //log.debug("Treatment findTreatmentById found: " + trList.get(0).log());
            return trList.get(0);
        }
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:23,代码来源:DatabaseHelper.java

示例12: getDanaRHistoryRecordsByType

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
    List<DanaRHistoryRecord> historyList;
    try {
        QueryBuilder<DanaRHistoryRecord, String> queryBuilder = getDaoDanaRHistory().queryBuilder();
        queryBuilder.orderBy("recordDate", false);
        Where where = queryBuilder.where();
        where.eq("recordCode", type);
        queryBuilder.limit(200L);
        PreparedQuery<DanaRHistoryRecord> preparedQuery = queryBuilder.prepare();
        historyList = getDaoDanaRHistory().query(preparedQuery);
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
        historyList = new ArrayList<>();
    }
    return historyList;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:17,代码来源:DatabaseHelper.java

示例13: getLastCareportalEvent

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Nullable
public CareportalEvent getLastCareportalEvent(String event) {
    try {
        List<CareportalEvent> careportalEvents;
        QueryBuilder<CareportalEvent, Long> queryBuilder = getDaoCareportalEvents().queryBuilder();
        queryBuilder.orderBy("date", false);
        Where where = queryBuilder.where();
        where.eq("eventType", event);
        queryBuilder.limit(1L);
        PreparedQuery<CareportalEvent> preparedQuery = queryBuilder.prepare();
        careportalEvents = getDaoCareportalEvents().query(preparedQuery);
        if (careportalEvents.size() == 1)
            return careportalEvents.get(0);
        else
            return null;
    } catch (SQLException e) {
        log.error("Unhandled exception", e);
    }
    return null;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:21,代码来源:DatabaseHelper.java

示例14: internalProcess

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
@Override
protected boolean internalProcess(AlerterContext context) throws SQLException {
  // get all actions that user did after joining.
  if (System.currentTimeMillis() < TIME_TO_WAIT_MS + context.dbAlertObject.enqueueTimestampMs) {
    context.dbAlertObject.nextCheckTimestampMs = context.dbAlertObject.enqueueTimestampMs + TIME_TO_WAIT_MS;
    return false;
  }
  QueryBuilder<DBProcessedAudit,Integer> builder = getBuilder(context, CANCEL_ALERT_ACTIONS, AlertUserType.ACTOR);

  // for some reason limit(int) is deprecated, WTF.
  builder.limit(1L);
  builder.setCountOf(true);
  
  if (context.manager.processedAuditDao.countOf(builder.prepare()) == 0) {
    // no such actions have happened. we should trigger the alert.
    logger.warn("should send unimplemented email for idle user");
    // TODO: send idle user email
  }
  return true;
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:21,代码来源:NewInactiveUserEmailer.java

示例15: getInteractionList

import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
private List<Interaction> getInteractionList() throws SQLException {
	QueryBuilder<Interaction, String> builder = Backend.getInteractionDao().queryBuilder();
	builder.limit((long) 100); // how many to return
	builder.orderBy("LASTEDITED", false);  // true for ascending, false for descending
	List<Interaction> list = Backend.getInteractionDao().query(builder.prepare()); 
	return list;		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:InteractionTabController.java


注:本文中的com.j256.ormlite.stmt.QueryBuilder.limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。