本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder.offset方法的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder.offset方法的具体用法?Java QueryBuilder.offset怎么用?Java QueryBuilder.offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.stmt.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.offset方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getAll
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Return a list of all entities
*
* @return
* @throws IOException
*/
public List<T> getAll(Long limit, Long offset) throws IOException {
try {
QueryBuilder builder = dao.queryBuilder();
if (limit != -1l) {
builder.limit(limit);
}
if (offset != -1l) {
builder.offset(offset);
}
return builder.query();
} catch (SQLException e) {
throw new IOException(e);
}
}
示例10: getLasts
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Get customers ordered by creation date desc
*
* @param limit
* @param offset
* @return
* @throws IOException
*/
public List<Customer> getLasts(long limit, long offset) throws IOException {
try {
QueryBuilder<Customer, String> builder = dao.queryBuilder();
builder.orderBy(Customer.CREATIONDATE_FIELD_NAME, false);
builder.limit(limit);
if (offset > 0) {
builder.offset(offset);
}
return builder.query();
} catch (Exception e) {
throw new IOException(e);
}
}
示例11: getNextCheckouts
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
/**
* Get future checkouts
*
* @param limit
* @param offset
* @return
* @throws IOException
*/
public List<Reservation> getNextCheckouts(long limit, long offset) throws IOException {
try {
QueryBuilder<Reservation, String> builder = dao.queryBuilder();
DateTime now = new DateTime();
DateTime start = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0).minusHours(2);
DateTime future = start.plusYears(1);
Where<Reservation, String> where = builder.where();
where.between(Reservation.DATEEND_FIELD_NAME, start.toDate(), future.toDate());
builder.orderBy(Reservation.DATEEND_FIELD_NAME, true);
builder.limit(limit);
if (offset > 0) {
builder.offset(offset);
}
List<Reservation> results = builder.query();
refresh(results);
return results;
} catch (Exception e) {
throw new IOException(e);
}
}
示例12: getByCustomerId
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Reservation> getByCustomerId(Long customerId, Boolean paid, long limit, long offset, boolean orderAscending) throws IOException {
try {
QueryBuilder queryBuilder = dao.queryBuilder();
Where where = queryBuilder.where();
// search for paid or non-paid only
if (paid != null) {
where.and(
where.eq(Reservation.CUSTOMER_FIELD_NAME, customerId),
where.eq(Reservation.PAID_FIELD_NAME, paid)
);
}
// search by customer id
else {
where.eq(Reservation.CUSTOMER_FIELD_NAME, customerId);
}
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);
}
}
示例13: search
import com.j256.ormlite.stmt.QueryBuilder; //导入方法依赖的package包/类
public List<Customer> search(String firstname, String lastname, String phonenumber, long limit, long offset) throws IOException {
if ((firstname == null || firstname.isEmpty())
&& (lastname == null || lastname.isEmpty())
&& (phonenumber == null || phonenumber.isEmpty())) {
throw new NullPointerException("Name or first name must be not null and not empty: n/" + lastname + ", fn/" + firstname);
}
String rawWhere = "";
// prepare arguments
// to lowercase, and replace all special chars by wildcards
lastname = lastname.trim().toLowerCase().replaceAll("[^a-z0-9]", "_");
firstname = firstname.trim().toLowerCase().replaceAll("[^a-z0-9]", "_");
phonenumber = phonenumber.trim().toLowerCase().replaceAll("[^a-z0-9]", "_");
// check first name
if (firstname.matches("^_*$") == false && firstname.isEmpty() == false) {
rawWhere += "LOWER(" + Customer.FIRSTNAME_FIELD_NAME + ") LIKE '%" + firstname + "%'";
}
// check last name
if (lastname.matches("^_*$") == false && lastname.isEmpty() == false) {
if (rawWhere.isEmpty() == false) {
rawWhere += " AND ";
}
rawWhere += "LOWER(" + Customer.LASTNAME_FIELD_NAME + ") LIKE '%" + lastname + "%'";
}
// check phone number
if (phonenumber.matches("^_*$") == false && phonenumber.isEmpty() == false) {
if (rawWhere.isEmpty() == false) {
rawWhere += " AND ";
}
rawWhere += "LOWER(" + Customer.PHONENUMBER_FIELD_NAME + ") LIKE '%" + phonenumber + "%'";
}
// do not query if arguments are not significant
if (rawWhere.isEmpty()) {
throw new IOException("Terms of research are not significant");
}
try {
QueryBuilder builder = dao.queryBuilder();
builder.where().raw(rawWhere);
builder.limit(limit);
builder.offset(offset);
return builder.query();
} catch (Exception e) {
throw new IOException(e);
}
}