Can I use Slice with findAll method : Spring Data
java, spring, spring-data, spring-data-jpa
Solution
It is possible to use `Slice` with `findAll()` - you just need to extend the correct Spring JPA Repository.
It won't work if you extend `JpaRepository`, because it extends `PagingAndSortingRepository` and there's already `findAll(Pageable pageable)` method defined in the Paging repository.
If you extend `CrudRepository` then you will be able to define method `Slice<T> findAll(Pageable pageable)` in your repository.
Problem
What i want : skip the count query that spring performs with `findAll(Pageable)`. I found that there is `Slice` datatype for such UIs (next based) where there is no need for total records/pages hence no need for count query. I can use `Slice` return type for methods like `findByName(Pageable)` etc but if i use Slice for findAll(Pageable) then it still performs the count query. Is there a workaround where i am able to use slice for `findAll` avoiding the count query? P.S. : i want the features that slice provide like - hasNext, size etc and i don't need to use Specification as well. Any help is appreciated.