當前位置: 首頁>>代碼示例>>Java>>正文


Java Pageable.getOffset方法代碼示例

本文整理匯總了Java中org.springframework.data.domain.Pageable.getOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java Pageable.getOffset方法的具體用法?Java Pageable.getOffset怎麽用?Java Pageable.getOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.domain.Pageable的用法示例。


在下文中一共展示了Pageable.getOffset方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createOptions

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
/**
 * build options map for tarantool paging request
 * @param pageable spring-data pageable (page size and offset provider)
 * @param iterator tarantool iterator
 * @return map to push into tarantool
 */
public static Map<String, Object> createOptions(Pageable pageable, Iterator iterator) {
    Map<String, Object> options = new HashMap<>();
    if (pageable.getPageSize() != Integer.MAX_VALUE) {
        options.put("limit", pageable.getPageSize());
    }
    if (pageable.getOffset() != 0) {
        options.put("offset", pageable.getOffset());
    }
    if (iterator != null) {
        options.put("iterator", iterator.getValue());
    }
    return options;
}
 
開發者ID:saladinkzn,項目名稱:spring-data-tarantool,代碼行數:20,代碼來源:TarantoolPageUtils.java

示例2: fromPageable

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
private <T> Stream<T> fromPageable(Page<T> result, Pageable pageable,
        Query<T, ?> query) {
    List<T> items = result.getContent();

    int firstRequested = query.getOffset();
    int nrRequested = query.getLimit();
    int firstReturned = (int) pageable.getOffset();
    int firstReal = firstRequested - firstReturned;
    int afterLastReal = firstReal + nrRequested;
    if (afterLastReal > items.size()) {
        afterLastReal = items.size();
    }
    return items.subList(firstReal, afterLastReal).stream();
}
 
開發者ID:Artur-,項目名稱:spring-data-provider,代碼行數:15,代碼來源:PageableDataProvider.java

示例3: findAll

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
/**
 * 分頁條件查詢
 * @param cq 條件
 * @param pageable 分頁信息
 * @param <T> 領域類(實體類)範型
 * @return 分頁結果
 */
public static <T> Page<T> findAll(CriteriaQuery<T> cq, Pageable pageable) {
	Class<T> domainClass = cq.getResultType();
	Root<T> root;
	if (CollectionUtils.isEmpty(cq.getRoots())) {
		root = cq.from(domainClass);
	} else {
		root = (Root<T>) cq.getRoots().iterator().next();
	}
	EntityManager em = getEntityManager(domainClass);
	if (pageable == null) {
		List<T> list = findAll(cq);
		return new PageImpl<T>(list);
	} else {
		Sort sort = pageable.getSort();
		cq.orderBy(QueryUtils.toOrders(sort, root, em.getCriteriaBuilder()));
		TypedQuery<T> query = em.createQuery(cq);
		
		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = count(cq);
		List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T> emptyList();

		return new PageImpl<T>(content, pageable, total);
	}
}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:35,代碼來源:JpaUtil.java

示例4: paging

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
public <T> Page<T> paging(Pageable pageable) {
	if (parent != null) {
		applyPredicateToCriteria(sq);
		return parent.paging(pageable);
	}
	List<T> list;
	if (pageable == null) {
		list = list();
		return new PageImpl<T>(list);
	} else {
		Sort sort = pageable.getSort();
		if (sort != null) {
			orders.addAll(QueryUtils.toOrders(sort, root, cb));
		}
		applyPredicateToCriteria(criteria);
		TypedQuery<?> query = em.createQuery(criteria);
		
		query.setFirstResult(pageable.getOffset());
		query.setMaxResults(pageable.getPageSize());

		Long total = JpaUtil.count(criteria);
		List<T> content = Collections.<T> emptyList();
		if (total > pageable.getOffset()) {
			content = transform(query, false);
		}

		return new PageImpl<T>(content, pageable, total);
	}
}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:31,代碼來源:LinqImpl.java

示例5: readPage

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
    query.setFirstResult(pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());

    final Long total = QueryUtils.executeCountQuery(getCountQuery(spec));
    final List<T> content = total > pageable.getOffset() ? query.getResultList() : Collections.<T>emptyList();

    if (total > maximumRecords) {
        return new CustomPageImpl<>(content, pageable, maximumRecords, String.format(ERROR_MESSAGE, maximumRecords));
    } else {
        return new PageImpl<>(content, pageable, total);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:15,代碼來源:CustomSimpleMaxedJpaRepository.java

示例6: getPageQuery

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
public String getPageQuery(Pageable pageable) {
	int offset = pageable.getOffset()+1;
	return generateRowNumSqlQueryWithNesting(getSelectClause(), false, "TMP_ROW_NUM >= "
			+ offset + " AND TMP_ROW_NUM < " + (offset+pageable.getPageSize()));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dashboard,代碼行數:7,代碼來源:OraclePagingQueryProvider.java

示例7: getPageQuery

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
public String getPageQuery(Pageable pageable) {
	int offset = pageable.getOffset() + 1;
	return generateRowNumSqlQueryWithNesting(getSelectClause(), false,
			"TMP_ROW_NUM BETWEEN " + offset + " AND " + (offset + pageable.getPageSize()));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dashboard,代碼行數:7,代碼來源:Db2PagingQueryProvider.java

示例8: find

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
public <X> Page<X> find(String hql, String countHql, Map<String, ?> params, Pageable pageable, Class<X> clazz) {
    long total = count(countHql, params);
    List<X> content = total > pageable.getOffset() ? find(hql, params, pageable, clazz) : Lists.newArrayList();
    return new PageImpl<>(content, pageable, total);
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:7,代碼來源:BaseRepositoryImpl.java

示例9: findByNative

import org.springframework.data.domain.Pageable; //導入方法依賴的package包/類
@Override
public <X> Page<X> findByNative(String sql, String countSql, List<?> params, Pageable pageable, Class<X> clazz) {
    long total = countByNative(countSql, params);
    List<X> content = total > pageable.getOffset() ? findByNative(sql, params, pageable, clazz) : Lists.newArrayList();
    return new PageImpl<>(content, pageable, total);
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:7,代碼來源:BaseRepositoryImpl.java


注:本文中的org.springframework.data.domain.Pageable.getOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。