The way to achieve this is simply by using List
as 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 engine would apply the offset and pagesize as handed in by the Pageable
but not trigger the additional count query as we don't need to construct a Page
instance. This also documented in the relevant sections of the reference documentation.
Update: If you want the next page / previous page of Page
but still skip the count query you may use Slice
as the return value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…