private static boolean isUnpaged(Pageable pageable) { return pageable.isUnpaged(); }
/** * Sets the given pagination information on the {@link Query} instance. Will transparently set {@code skip} and * {@code limit} as well as applying the {@link Sort} instance defined with the {@link Pageable}. * * @param pageable * @return */ public Query with(Pageable pageable) { if (pageable.isUnpaged()) { return this; } this.limit = pageable.getPageSize(); this.skip = pageable.getOffset(); return with(pageable.getSort()); }
/** * Binds the parameters to the given query and applies special parameter types (e.g. pagination). * * @param query must not be {@literal null}. * @param values values of method parameters to be assigned to the query parameters. */ Query bindAndPrepare(Query query, Object[] values) { Assert.notNull(query, "Query must not be null!"); ParametersParameterAccessor accessor = new ParametersParameterAccessor(parameters, values); Query result = bind(query, values); if (!useJpaForPaging || !parameters.hasPageableParameter() || accessor.getPageable().isUnpaged()) { return result; } result.setFirstResult((int) accessor.getPageable().getOffset()); result.setMaxResults(accessor.getPageable().getPageSize()); return result; } }
/** * Applies the given {@link Pageable} to the given {@link JPQLQuery}. * * @param pageable * @param query must not be {@literal null}. * @return the Querydsl {@link JPQLQuery}. */ public <T> JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query) { if (pageable.isUnpaged()) { return query; } query.offset(pageable.getOffset()); query.limit(pageable.getPageSize()); return applySorting(pageable.getSort(), query); }
/** * Sets the given pagination information on the {@link Query} instance. Will transparently set {@code skip} and * {@code limit} as well as applying the {@link Sort} instance defined with the {@link Pageable}. * * @param pageable * @return */ public Query with(Pageable pageable) { if (pageable.isUnpaged()) { return this; } this.limit = pageable.getPageSize(); this.skip = pageable.getOffset(); return with(pageable.getSort()); }
private static boolean isUnpaged(Pageable pageable) { return pageable.isUnpaged(); }
private static boolean isUnpaged(Pageable pageable) { return pageable.isUnpaged(); }
/** * Returns an {@link Optional} so that it can easily be mapped on. * * @return */ default Optional<Pageable> toOptional() { return isUnpaged() ? Optional.empty() : Optional.of(this); } }
public static String buildLimitClause(final Pageable pageable) { if (pageable.isUnpaged()) { return ""; } final StringJoiner clause = new StringJoiner(", ", "LIMIT ", ""); clause.add(String.valueOf(pageable.getOffset())); clause.add(String.valueOf(pageable.getPageSize())); return clause.toString(); }
public static String buildLimitClause(final Pageable pageable) { if (pageable.isUnpaged()) { return ""; } final StringJoiner clause = new StringJoiner(", ", "LIMIT ", ""); clause.add(String.valueOf(pageable.getOffset())); clause.add(String.valueOf(pageable.getPageSize())); return clause.toString(); }
private static StringBuilder buildPageableClause( final Pageable pageable, @Nullable final String varName, final StringBuilder clause) { if (pageable.isUnpaged()) { return clause; } final Sort sort = pageable.getSort(); buildSortClause(sort, varName, clause); if (sort.isSorted()) { clause.append(' '); } clause.append("LIMIT ").append(pageable.getOffset()).append(", ").append(pageable.getPageSize()); return clause; }
private static StringBuilder buildPageableClause( final Pageable pageable, @Nullable final String varName, final StringBuilder clause) { if (pageable.isUnpaged()) { return clause; } final Sort sort = pageable.getSort(); buildSortClause(sort, varName, clause); if (sort.isSorted()) { clause.append(' '); } clause.append("LIMIT ").append(pageable.getOffset()).append(", ").append(pageable.getPageSize()); return clause; }
private <R> Page<R> readPageWithProjection(Specification<T> spec, Class<R> projectionType, Pageable pageable, TypedQuery<T> query) { if (log.isDebugEnabled()) { query.getHints().forEach((key, value) -> log.info("apply query hints -> {} : {}", key, value)); } Page<T> result = pageable.isUnpaged() ? new PageImpl<>(query.getResultList()) : readPage(query, getDomainClass(), pageable, spec); return result.map(item -> projectionFactory.createProjection(projectionType, item)); }
/** * @param criteria * @param pageable */ public SimpleQuery(Criteria criteria, @Nullable Pageable pageable) { super(criteria); if (pageable != null && !pageable.isUnpaged()) { this.offset = pageable.getOffset(); this.rows = pageable.getPageSize(); this.addSort(pageable.getSort()); } }
@Override public <X extends T> Page<T> findAll(Pageable pageable, X condition) { if (null == pageable || pageable.isUnpaged()) { // FIXME USE A DEFAULT PAGEABLE? return new PageImpl<>(findAll(condition)); } return findByPager(pageable, "__find_by_pager", "__count", condition); }
/** * Binds the parameters to the given query and applies special parameter types (e.g. pagination). * * @param query must not be {@literal null}. * @param values values of method parameters to be assigned to the query parameters. */ Query bindAndPrepare(Query query, Object[] values) { Assert.notNull(query, "Query must not be null!"); ParametersParameterAccessor accessor = new ParametersParameterAccessor(parameters, values); Query result = bind(query, values); if (!useJpaForPaging || !parameters.hasPageableParameter() || accessor.getPageable().isUnpaged()) { return result; } result.setFirstResult((int) accessor.getPageable().getOffset()); result.setMaxResults(accessor.getPageable().getPageSize()); return result; } }
@Override public Page<T> findAll(Pageable pageable) { Assert.notNull(pageable, "Pageable must not be null!"); if (pageable.isUnpaged()) { List<T> result = findAll(); return new PageImpl<>(result, Pageable.unpaged(), result.size()); } Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(), entityInformation.getJavaType()); return new PageImpl<>(IterableConverter.toList(content), pageable, this.operations.count(entityInformation.getJavaType())); }
@Override public Page<T> findAll(Pageable pageable) { Assert.notNull(pageable, "Pageable must not be null!"); if (pageable.isUnpaged()) { List<T> result = findAll(); return new PageImpl<>(result, Pageable.unpaged(), result.size()); } Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(), entityInformation.getJavaType()); return new PageImpl<>(IterableConverter.toList(content), pageable, this.operations.count(entityInformation.getJavaType())); }
/** * Applies the given {@link Pageable} to the given {@link JPQLQuery}. * * @param pageable * @param query must not be {@literal null}. * @return the Querydsl {@link JPQLQuery}. */ public <T> JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query) { if (pageable.isUnpaged()) { return query; } query.offset(pageable.getOffset()); query.limit(pageable.getPageSize()); return applySorting(pageable.getSort(), query); }
@Override public Page<T> findAll(Pageable pageable) { Assert.notNull(pageable, "Pageable must not be null!"); if (pageable.isUnpaged()) { List<T> result = findAll(); return new PageImpl<>(result, Pageable.unpaged(), result.size()); } Iterable<T> content = operations.findInRange(pageable.getOffset(), pageable.getPageSize(), pageable.getSort(), entityInformation.getJavaType()); return new PageImpl<>(IterableConverter.toList(content), pageable, this.operations.count(entityInformation.getJavaType())); }