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


Java QueryBuilder.offset方法代码示例

本文整理汇总了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);
            }
        }
    }
 
开发者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: 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);
    }
}
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:21,代码来源:AbstractDaoService.java

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

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

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

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

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


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