In My Spring MVC application, I am using spring-data-jpa with MySql Data Base. For a data table trying to implement pagination.
On the table there are 191 records,and 'id' is the primary key - the value of starting from 10, 11, 12 ---- 199, 200.
My each page contains suppose 10 records.
following is the code I am using to fetch only 10 records from the table.
Pageable pageable = new PageRequest(firstResult, maxResults);
Page<User> findAll2 = repository.findAll(pageable);
For Page 1 -> firstResult = 1 and maxResults = 10
Pageable pageable = new PageRequest(1, 10);
Here I am getting 10 records, the id 20 to 29
But I am expecting from 10 to 19
For Page 2 -> firstResult = 11 and maxResults = 10
Pageable pageable = new PageRequest(11, 10);
Here I am getting 10 records, the id 120 to 129
what about other records.
Now
For Page 3 ->firstResult = 21 and maxResults = 10
Pageable pageable = new PageRequest(21, 10);
Here I am NOT getting any record.
All values are null.Not sure what I am missing.please help me on this.