I want to get all the results in single page, I've tried with
Pageable p = new PageRequest(1, Integer.MAX_VALUE); return customerRepository.findAll(p);
Above is not working, is there any methods to achieve this? Seems like it cannot be achieved from custom query as asked here.
Once we have our repository extending from PagingAndSortingRepository, we just need to: Create or obtain a PageRequest object, which is an implementation of the Pageable interface. Pass the PageRequest object as an argument to the repository method we intend to use.
You can use the JPA pagination for both entity queries and native SQL. To limit the underlying query ResultSet size, the JPA Query interface provides the setMaxResults method. Navigating the following page requires positioning the result set where the last page ended.
PagingAndSortingRepository PagingAndSortingRepository is an extension of CrudRepository to provide additional methods to retrieve entities using the pagination and sorting abstraction.
The more correct way is to use Pageable.unpaged()
Pageable wholePage = Pageable.unpaged(); return customerRepository.findAll(wholePage);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With