-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
When it comes to pagination, we may either use Page or Slice. The Slice allows for trivial pagination where we do not really need to know the total amount of records in the database that potentially satisfy our criteria, so there is no need for the subsequent COUNT query.
The Slice itself is very useful, but unfortunately currently it is not that easy to use with Specifications. The JpaSpecificationExecutor defines methods like:
List<T> findAll(@Nullable Specification<T> spec);
Page<T> findAll(@Nullable Specification<T> spec, Pageable pageable);
List<T> findAll(@Nullable Specification<T> spec, Sort sort);
But sometimes just Slice would suffice. There are some solutions that people came up with, please, see this StackOverFlow thread and the corresponding solution (extension of SimpleJpaRepository, providing a custom RepositoryFactoryBean and etc.).
I want to kindly ask to consider the introduction of method like:
Slice<T> findAll(@Nullable Specification<T> spec, Pageable pageable);
So this method both accepts the Pageable, but it returns the Slice, not the Page.