本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder.orderBy方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder.orderBy方法的具体用法?Java QueryBuilder.orderBy怎么用?Java QueryBuilder.orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.stmt.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例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: getTopScore
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 返回最高得分
*
* @return
*/
public GameRanking getTopScore()
{
QueryBuilder<GameRanking, ?> qb = getDao().queryBuilder();
try
{
// qb.where().eq("user_name", userName);
qb.orderBy("score", false);
return qb.queryForFirst();
}
catch (SQLException e)
{
e.printStackTrace();
}
return null;
}
示例4: 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;
}
示例5: 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;
}
示例6: getBranchBookingsForUser
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Returns all the bookings for a given branch and a given user in the SQLite database
*
* @param branch the specified branch
* @param user the specified user
* @return a list of the matching bookings
*/
@Override
public List<Booking> getBranchBookingsForUser(Branch branch, User user) {
try {
QueryBuilder<Booking, Integer> statementBuilder = dao.queryBuilder();
Where whereClause = statementBuilder.where();
whereClause
.eq(Booking.BRANCH_FIELD_NAME, branch)
.and()
.eq(Booking.USER_FIELD_NAME, user);
statementBuilder.orderBy(Booking.START_DAY_FIELD_NAME, true);
return dao.query(statementBuilder.prepare());
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
示例7: getBranchBookings
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Returns all the bookings for a given branch in the SQLite database
*
* @param currentBranch the specified branch
* @return a list of the matching bookings
*/
@Override
public List<Booking> getBranchBookings(Branch currentBranch) {
try {
QueryBuilder<Booking, Integer> statementBuilder = dao.queryBuilder();
Where whereClause = statementBuilder.where();
whereClause.eq(Booking.BRANCH_FIELD_NAME, currentBranch);
statementBuilder.orderBy(Booking.START_DAY_FIELD_NAME, true);
return dao.query(statementBuilder.prepare());
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
示例8: 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;
}
示例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: queryForFirstByOrder
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* 排序查询
*
* @param map 查询条件键值组合
* @param orderColumn 排序的列
* @param ascending 是否升序
* @return
*/
public T queryForFirstByOrder(Map<String, Object> map, String orderColumn, boolean ascending) {
T t = null;
QueryBuilder<T, Integer> queryBuilder = ormLiteDao.queryBuilder();
Where where = queryBuilder.where();
try {
queryBuilder.orderBy(orderColumn, ascending);
where.isNotNull("id");
for (Map.Entry<String, Object> entry : map.entrySet()) {
where.and().eq(entry.getKey(), entry.getValue());
}
t = queryBuilder.queryForFirst();
} catch (SQLException e) {
LogUtils.e(e);
}
return t;
}
示例11: 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;
}
示例12: getBgreadingsDataFromTime
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<BgReading> getBgreadingsDataFromTime(long mills, boolean ascending) {
try {
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
List<BgReading> bgReadings;
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills).and().gt("value", 38);
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
bgReadings = daoBgreadings.query(preparedQuery);
return bgReadings;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<BgReading>();
}
示例13: getTreatmentDataFromTime
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
try {
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
List<Treatment> treatments;
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills);
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
treatments = daoTreatments.query(preparedQuery);
return treatments;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<Treatment>();
}
示例14: getTemptargetsDataFromTime
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<TempTarget> getTemptargetsDataFromTime(long mills, boolean ascending) {
try {
Dao<TempTarget, Long> daoTempTargets = getDaoTempTargets();
List<TempTarget> tempTargets;
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
queryBuilder.orderBy("date", ascending);
Where where = queryBuilder.where();
where.ge("date", mills);
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
tempTargets = daoTempTargets.query(preparedQuery);
return tempTargets;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<TempTarget>();
}
示例15: 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;
}