Skip to content
Advertisement

paging and sorting with Jpa returns only around 10% records from db

When I try to retrieve data from JpaRepository with Pageable request it only return 10% from all records. as example I had 68 records in MySQL database and pageble request only return first 10 records. when i try to get 2nd resultset it returns empty page content object.

but if I request 100 records in one request it return all 68 records.

I just try this with JpaRepository and PagingAndSortingRepository too. but its same result

if anyone can explain the reason I will really appreciate it. Thank You!

** Updated **

** request object **

** 2nd Page Request **

Advertisement

Answer

Javadoc for PageRequest.of states:

You need to pass page number instead of row number as the first parameter (start: 1 in second request). Otherwise, you’re taking 10-th page in 0-based indexing, so you should have more than 100 rows to get anything.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement