The way to achieve this is to simply use List as the return value. So, for example, for a repository defined like this:
interface CustomerRepository extends Repository<Customer, Long> { List<Customer> findByLastname(String lastname, Pageable pageable); }
The query execution mechanism applies the offset and page size as passed to Pageable but does not start the request of the additional counter, since we do not need to create a Page instance. This is also documented in the relevant sections of the reference documentation.
Update: if you want to go to the next / previous Page but skip the counting request, you can use Slice as the return value.
Oliver drotbohm
source share