I am making a springboot pagination however :
repo.findAll (PageRequest.of (page, size) );
Doesn't seem to work.
Does anybody know the new way to paginate in spring boot 2+ after PageRequest(...) is deprecated?
Thanks in advance.
I am making a springboot pagination however :
repo.findAll (PageRequest.of (page, size) );
Doesn't seem to work.
Does anybody know the new way to paginate in spring boot 2+ after PageRequest(...) is deprecated?
Thanks in advance.
You need a Pageable
object. Sample snippet:
@Repository
public interface MyRepo extends JpaRepository<MyDto, Long> {
Page<MyEntity> findAll(Pageable page);
}
`If you get the Pageable object from the controller, just pass it on or else if you want to manually construct, you can do like follows:
@Test
public void testPagination(){
assertNotNull(myRepo.findAll(PageRequest.of(0, 20)));
}
This works for me! Make sure you return Page<MyEntity>
instead of List?
My mistake : repo.findAll (PageRequest.of (page, size) ); ... is a working methodology. Thanks for your tme @karthik R