I want to get first 20
records, I have response time as 200
After some time (By calling the same service) I want another 20
records.
By each hit I want to get 20
records. How can I implement this?
I am using Spring ,hibernate and angular as front-end.
Please provide a solution .
Thanks in advance.
Use spring-data-rest, you should be able to expose your hibernate entity to the user in a RESTful way. Using the auto generated end points you should be able to perform POST/PUT/GET/DELETE. When you expose the entity, the pagination is by default available for you.
By making use of spring-data-rest your scenario could be solved by giving a page size in the (GET) REST response
Example:
For instance assume that you have 200 user records in your DB and you want server 20 records per request,then the GET REST URL will be look like this:
http://localhost:8080/users?page=1&size=5
There are 2 key information to be noted:
page - the page number to access (0 indexed, defaults to 0).
size - the page size requested (defaults to 20).
So to get first 20 records, user will issue a request like: http://localhost:8080/users or http://localhost:8080/users?page=0&size=20
To access next 20 items, change the page number alone: http://localhost:8080/users?page=1
Since default size is 20, in you case you can omit that; but if you decide to modify the size, say 25 or 30, then you should be able to supply that as part of size param.