/** * Creates a new count query for the given {@link Specification}. * * @param spec can be {@literal null}. * @return * @deprecated override {@link #getCountQuery(Specification, Class)} instead */ @Deprecated protected TypedQuery<Long> getCountQuery(@Nullable Specification<T> spec) { return getCountQuery(spec, getDomainClass()); }
@Override public long count(@Nullable Specification<T> spec) { return executeCountQuery(getCountQuery(spec, getDomainClass())); }
@Override public <S extends T> long count(Example<S> example) { return executeCountQuery(getCountQuery(new ExampleSpecification<S>(example), example.getProbeType())); }
/** * Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and * {@link Specification}. * * @param query must not be {@literal null}. * @param domainClass must not be {@literal null}. * @param spec can be {@literal null}. * @param pageable can be {@literal null}. * @return */ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> domainClass, Pageable pageable, @Nullable Specification<S> spec) { if (pageable.isPaged()) { query.setFirstResult((int) pageable.getOffset()); query.setMaxResults(pageable.getPageSize()); } return PageableExecutionUtils.getPage(query.getResultList(), pageable, () -> executeCountQuery(getCountQuery(spec, domainClass))); }
/** * Creates a new count query for the given {@link Specification}. * * @param spec can be {@literal null}. * @return * @deprecated override {@link #getCountQuery(Specification, Class)} instead */ @Deprecated protected TypedQuery<Long> getCountQuery(@Nullable Specification<T> spec) { return getCountQuery(spec, getDomainClass()); }
public long count(@Nullable Specification<T> spec) { return executeCountQuery(getCountQuery(spec, getDomainClass())); }
@Override @SuppressWarnings("unchecked") protected <S extends T> TypedQuery<Long> getCountQuery(Specification<S> spec, Class<S> domainClass) { return super.getCountQuery(((Specifications<S>)aclJpaSpec()).and(spec), domainClass); }
@Override public <S extends T> long count(Example<S> example) { return executeCountQuery(getCountQuery(new ExampleSpecification<S>(example), example.getProbeType())); }
/** * Reads the given {@link TypedQuery} into a {@link Page} applying the given {@link Pageable} and * {@link Specification}. * * @param query must not be {@literal null}. * @param domainClass must not be {@literal null}. * @param spec can be {@literal null}. * @param pageable can be {@literal null}. * @return */ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> domainClass, Pageable pageable, @Nullable Specification<S> spec) { if (pageable.isPaged()) { query.setFirstResult((int) pageable.getOffset()); query.setMaxResults(pageable.getPageSize()); } return PageableExecutionUtils.getPage(query.getResultList(), pageable, () -> executeCountQuery(getCountQuery(spec, domainClass))); }