Reputation: 51
I have 10000 records in database i want to fetch 100 record first time next 100 record 2nd time and so on. I'm using setFirstResult()
and maxResult()
. I'm maintaining a counter to update set first result offset setFirstResult(count)
is always started from first index whatever value you put inside it, it start from 0.
List<StudentBo> bos=manager.createNamedQuery("getAllApplicantForRegistration")
.setParameter("batch",dto.getBatch())
.setFirstResult(count)
.setMaxResult(lastIndex).getResultList();
Upvotes: 0
Views: 105
Reputation: 51
setFirstResult will incease every time while setMaxResult will be static.
Upvotes: 1