當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。