Scenario
A query fetches 1000 records from the table.
The data will be returned as collection. What is the correct approach.
a) Get all the records and paginate them in web layer
b) Get only some records at a time and when user asks more more, fetch more
What do you think is correct approach ?
Answer
Solution b and this can be implemented using paging in hibernate.
Query query = session.createFilter( collection, "" );
query.setMaxResults(PAGE_SIZE);
query.setFirstResult(PAGE_SIZE * pageNumber);
List page = query.list();
No comments:
Post a Comment
Note: only a member of this blog may post a comment.