本文整理匯總了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;
}