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