congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
PageableExecutionUtils.getPage
Code IndexAdd Tabnine to your IDE (free)

How to use
getPage
method
in
org.springframework.data.repository.support.PageableExecutionUtils

Best Java code snippets using org.springframework.data.repository.support.PageableExecutionUtils.getPage (Showing top 20 results out of 315)

origin: spring-projects/spring-data-mongodb

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(predicate, "Predicate must not be null!");
  Assert.notNull(pageable, "Pageable must not be null!");
  SpringDataMongodbQuery<T> query = createQueryFor(predicate);
  return PageableExecutionUtils.getPage(applyPagination(query, pageable).fetch(), pageable, query::fetchCount);
}
origin: spring-projects/spring-data-jpa

@Override
@SuppressWarnings("unchecked")
protected Object doExecute(final AbstractJpaQuery repositoryQuery, final Object[] values) {
  ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);
  Query query = repositoryQuery.createQuery(values);
  return PageableExecutionUtils.getPage(query.getResultList(), accessor.getPageable(),
      () -> count(repositoryQuery, values));
}
origin: spring-projects/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}
origin: spring-projects/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}
origin: spring-projects/spring-data-jpa

/**
 * 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)));
}
origin: spring-projects/spring-data-mongodb

@Override
public <S extends T> Page<S> findAll(final Example<S> example, Pageable pageable) {
  Assert.notNull(example, "Sample must not be null!");
  Assert.notNull(pageable, "Pageable must not be null!");
  Query q = new Query(new Criteria().alike(example)).with(pageable);
  List<S> list = mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName());
  return PageableExecutionUtils.getPage(list, pageable,
      () -> mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName()));
}
origin: spring-projects/spring-data-mongodb

  @Override
  public Object execute(Query query) {
    int overallLimit = query.getLimit();
    TerminatingFind<?> matching = operation.matching(query);
    // Apply raw pagination
    query.with(pageable);
    // Adjust limit if page would exceed the overall limit
    if (overallLimit != 0 && pageable.getOffset() + pageable.getPageSize() > overallLimit) {
      query.limit((int) (overallLimit - pageable.getOffset()));
    }
    return PageableExecutionUtils.getPage(matching.all(), pageable, () -> {
      long count = matching.count();
      return overallLimit != 0 ? Math.min(count, overallLimit) : count;
    });
  }
}
origin: spring-projects/spring-data-mongodb

  @Override
  public Object execute(Query query) {
    GeoResults<Object> geoResults = doExecuteQuery(query);
    Page<GeoResult<Object>> page = PageableExecutionUtils.getPage(geoResults.getContent(), accessor.getPageable(),
        () -> {
          Query countQuery = mongoQuery.createCountQuery(accessor);
          countQuery = mongoQuery.applyQueryMetaAttributesWhenPresent(countQuery);
          return operation.matching(countQuery).count();
        });
    // transform to GeoPage after applying optimization
    return new GeoPage<>(geoResults, accessor.getPageable(), page.getTotalElements());
  }
}
origin: org.springframework.data/spring-data-mongodb

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(predicate, "Predicate must not be null!");
  Assert.notNull(pageable, "Pageable must not be null!");
  SpringDataMongodbQuery<T> query = createQueryFor(predicate);
  return PageableExecutionUtils.getPage(applyPagination(query, pageable).fetch(), pageable, query::fetchCount);
}
origin: spring-projects/spring-data-neo4j

  @Override
  public Page<T> findAll(Pageable pageable, int depth) {
    Pagination pagination = new Pagination(pageable.getPageNumber(), pageable.getPageSize());
    Collection<T> data = session.loadAll(clazz, PagingAndSortingUtils.convert(pageable.getSort()), pagination, depth);

    return PageableExecutionUtils.getPage(new ArrayList<>(data), pageable, () -> session.countEntitiesOfType(clazz));
  }
}
origin: org.springframework.data/spring-data-mongodb

@Override
public <S extends T> Page<S> findAll(final Example<S> example, Pageable pageable) {
  Assert.notNull(example, "Sample must not be null!");
  Assert.notNull(pageable, "Pageable must not be null!");
  Query q = new Query(new Criteria().alike(example)).with(pageable);
  List<S> list = mongoOperations.find(q, example.getProbeType(), entityInformation.getCollectionName());
  return PageableExecutionUtils.getPage(list, pageable,
      () -> mongoOperations.count(q, example.getProbeType(), entityInformation.getCollectionName()));
}
origin: org.springframework.data/spring-data-mongodb

  @Override
  public Object execute(Query query) {
    int overallLimit = query.getLimit();
    TerminatingFind<?> matching = operation.matching(query);
    // Apply raw pagination
    query.with(pageable);
    // Adjust limit if page would exceed the overall limit
    if (overallLimit != 0 && pageable.getOffset() + pageable.getPageSize() > overallLimit) {
      query.limit((int) (overallLimit - pageable.getOffset()));
    }
    return PageableExecutionUtils.getPage(matching.all(), pageable, () -> {
      long count = matching.count();
      return overallLimit != 0 ? Math.min(count, overallLimit) : count;
    });
  }
}
origin: org.springframework.data/spring-data-mongodb

  @Override
  public Object execute(Query query) {
    GeoResults<Object> geoResults = doExecuteQuery(query);
    Page<GeoResult<Object>> page = PageableExecutionUtils.getPage(geoResults.getContent(), accessor.getPageable(),
        () -> {
          Query countQuery = mongoQuery.createCountQuery(accessor);
          countQuery = mongoQuery.applyQueryMetaAttributesWhenPresent(countQuery);
          return operation.matching(countQuery).count();
        });
    // transform to GeoPage after applying optimization
    return new GeoPage<>(geoResults, accessor.getPageable(), page.getTotalElements());
  }
}
origin: spring-projects/spring-data-neo4j

@Override
public Object execute(Query query, Class<?> type) {
  List<?> result;
  long count;
  if (query.isFilterQuery()) {
    result = (List<?>) session.loadAll(type, query.getFilters(), accessor.getOgmSort(),
        query.getPagination(pageable, false), accessor.getDepth());
    count = session.count(type, query.getFilters());
  } else {
    if (type.getAnnotation(QueryResult.class) != null) {
      result = (List<?>) session.query(query.getCypherQuery(pageable, false), query.getParameters()).queryResults();
    } else {
      result = (List<?>) session.query(type, query.getCypherQuery(pageable, false), query.getParameters());
    }
    count = (result.size() > 0) ? countTotalNumberOfElements(query) : 0;
  }
  return PageableExecutionUtils.getPage(result, pageable, (LongSupplier) () -> count);
}
origin: org.springframework.data/spring-data-jpa

@Override
@SuppressWarnings("unchecked")
protected Object doExecute(final AbstractJpaQuery repositoryQuery, final Object[] values) {
  ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);
  Query query = repositoryQuery.createQuery(values);
  return PageableExecutionUtils.getPage(query.getResultList(), accessor.getPageable(),
      () -> count(repositoryQuery, values));
}
origin: alibaba/sca-best-practice

protected <T> Page<T> readPage(final Class<T> clazz, TypedQuery<T> query, Pageable pageable,
                @Nullable Specification<T> spec) {
  if (pageable.isPaged()) {
    query.setFirstResult((int)pageable.getOffset());
    query.setMaxResults(pageable.getPageSize());
  }
  return PageableExecutionUtils.getPage(query.getResultList(), pageable,
    () -> executeCountQuery(getCountQuery(clazz, spec)));
}
origin: org.springframework.data/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}
origin: org.springframework.data/spring-data-jpa

@Override
public Page<T> findAll(Predicate predicate, Pageable pageable) {
  Assert.notNull(pageable, "Pageable must not be null!");
  final JPQLQuery<?> countQuery = createCountQuery(predicate);
  JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
  return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchCount);
}
origin: hexagonframework/spring-data-ebean

@SuppressWarnings("unchecked")
<E> Page<E> findPage(Pageable pageable) {
  if (queryType == QUERY) {
    PagedList<E> pagedList = ((Query<E>) queryInstance)
        .setFirstRow((int) pageable.getOffset())
        .setMaxRows(pageable.getPageSize())
        .findPagedList();
    return PageableExecutionUtils.getPage(pagedList.getList(), pageable, pagedList::getTotalCount);
  }
  throw new IllegalArgumentException("query not supported!");
}
origin: com.epam.reportportal/commons-dao

/**
 * Finds page by provided {@link Query} and {@link Pageable} criterias
 *
 * @param q Query for entity
 * @param p Pageable descriptor
 * @return Page of entities
 */
Page<T> findPage(Query q, Pageable p) {
  Class<T> entityType = getEntityInformation().getJavaType();
  List<T> content = getMongoOperations().find(q, entityType);
  return PageableExecutionUtils.getPage(content, p, () -> getMongoOperations().count(q, entityType));
}
org.springframework.data.repository.supportPageableExecutionUtilsgetPage

Javadoc

Constructs a Page based on the given content, Pageable and Supplier applying optimizations. The construction of Page omits a count query if the total can be determined based on the result size and Pageable.

Popular methods of PageableExecutionUtils

    Popular in Java

    • Start an intent from android
    • getExternalFilesDir (Context)
    • onCreateOptionsMenu (Activity)
    • setRequestProperty (URLConnection)
    • URLConnection (java.net)
      A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
    • Charset (java.nio.charset)
      A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
    • Enumeration (java.util)
      A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
    • PriorityQueue (java.util)
      A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
    • ZipFile (java.util.zip)
      This class provides random read access to a zip file. You pay more to read the zip file's central di
    • DataSource (javax.sql)
      An interface for the creation of Connection objects which represent a connection to a database. This
    • Top 25 Plugins for Webstorm
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now