List of usage examples for org.springframework.data.domain Pageable getOffset
long getOffset();
From source file:cn.guoyukun.spring.jpa.repository.callback.DefaultSearchCallback.java
public void setPageable(Query query, Searchable search) { if (search.hasPageable()) { Pageable pageable = search.getPage(); query.setFirstResult(pageable.getOffset()); query.setMaxResults(pageable.getPageSize()); }//from w w w .j a va 2s.c om }
From source file:net.turnbig.jdbcx.dialect.impl.InformixDialect.java
@Override public String getPageableSql(String sql, Pageable pageable) { String sortedSql = SelectSqlUtils.addSort(sql, pageable.getSort()); String pagedSql = "select skip {1} first {2} * from ({0}) temp_t"; return MessageFormat.format(pagedSql, sortedSql, pageable.getOffset(), pageable.getPageSize()); }
From source file:com.excilys.ebi.bank.dao.impl.OperationDaoImpl.java
protected JPQLQuery applyPagination(JPQLQuery query, Pageable pageable) { return pageable != null ? query.offset(pageable.getOffset()).limit(pageable.getPageSize()) : query; }
From source file:at.pagu.soldockr.core.QueryParser.java
private void appendPagination(SolrQuery query, Pageable pageable) { if (pageable == null) { return;//w ww . j a va 2 s . c om } query.setStart(pageable.getOffset()); query.setRows(pageable.getPageSize()); }
From source file:com.github.obiteaaron.common.data.FixPageImpl.java
/** * Constructor of {@code PageImpl}./* w ww . j a v a2 s . c o m*/ * * @param content the content of this page, must not be {@literal null}. * @param pageable the paging information, can be {@literal null}. * @param total the total amount of items available. The total might be adapted considering the length of the content * given, if it is going to be the content of the last page. This is in place to mitigate inconsistencies */ public FixPageImpl(List<T> content, Pageable pageable, long total) { super(content, pageable); this.total = !content.isEmpty() && pageable != null && pageable.getOffset() + pageable.getPageSize() > total ? pageable.getOffset() + content.size() : total; }
From source file:com.example.session.domain.service.goods.GoodsService.java
/** * ??????//from w ww.j a v a2 s. co m * * @param categoryId * @param pageable * @return */ public Page<Goods> findByCategoryId(Integer categoryId, Pageable pageable) { long total = goodsRepository.countByCategoryId(categoryId); List<Goods> goodsList = Collections.emptyList(); if (total > 0) { RowBounds rowBounds = new RowBounds((int) pageable.getOffset(), pageable.getPageSize()); goodsList = goodsRepository.findPageByCategoryId(categoryId, rowBounds); } return new PageImpl<Goods>(goodsList, pageable, total); }
From source file:org.lightadmin.core.web.RepositoryScopedSearchController.java
private Page<?> selectPage(List<Object> items, Pageable pageable) { final List<Object> itemsOnPage = items.subList(pageable.getOffset(), Math.min(items.size(), pageable.getOffset() + pageable.getPageSize())); return new PageImpl(itemsOnPage, pageable, items.size()); }
From source file:com.wiiyaya.framework.provider.repository.BaseDaoImpl.java
@Override public Page<T> findAllJF(JF joinFetch, Pageable pageable) { JPQLQuery countQuery = createQuery(); joinFetch.prepareQry(countQuery, false); Long total = countQuery.count(); List<T> content = null; if (total > pageable.getOffset()) { JPQLQuery query = querydsl.applyPagination(pageable, createQuery()); joinFetch.prepareQry(query, true); content = query.list(path);//from ww w. j a v a 2s.c om } else { content = Collections.<T>emptyList(); } return new PageImpl<T>(content, pageable, total); }
From source file:com.wiiyaya.framework.provider.repository.BaseDaoImpl.java
@Override public Page<Tuple> findAllJFTuple(JFTuple joinFetch, Pageable pageable) { JPQLQuery countQuery = createQuery(); joinFetch.prepareQry(countQuery, false); Long total = countQuery.count(); List<Tuple> content = null; if (total > pageable.getOffset()) { JPQLQuery query = querydsl.applyPagination(pageable, createQuery()); content = joinFetch.prepareQry(query, true); } else {/*from ww w. java 2s . c o m*/ content = Collections.<Tuple>emptyList(); } return new PageImpl<Tuple>(content, pageable, total); }
From source file:com.wiiyaya.framework.provider.repository.BaseDaoImpl.java
@Override public Page<T> findAll(Predicate predicate, Pageable pageable) { JPQLQuery countQuery = createWhereQuery(predicate); JPQLQuery query = querydsl.applyPagination(pageable, createWhereQuery(predicate)); Long total = countQuery.count(); List<T> content = total > pageable.getOffset() ? query.list(path) : Collections.<T>emptyList(); return new PageImpl<T>(content, pageable, total); }