Hello everybody,
I am a new member on this forum and the reason I became a member is because of the way I saw the behavior of the org.hibernate.Query object in Hibernate and I needed to understand how it works.
Specifically, I was using the Query.setFirstResult() and Query.setMaxResults() to make my pagination logic work. However, what I found is that the Query object was omitting certain records from the Database!!
For example; I had 12 records in one of my table named YOURSTORY. I wanted to display 3 record per page which means there were 4 pages to show. When I came to page no 1, the setFirstResult() was setting the value as 0 (zero) and setMaxResults() as 3. However, I got the record number 3, 4 and 5 from the YOURSTORY table. When I went to the page no 2, the setFirstResult() was setting the value as 3 and setMaxResults() as 3. This time I again got the record number 3, 4 and 5 from the same table which was correct. When I went to page no 3, the setFirstResult() was setting the value as 6 and setMaxResults() as 3. This time I got record number 6, 7 and 8 which was correct again. The same correctness was shown for the next page (page no 4 and record 9, 10 and 11) record.
The question to you all is why did I not get the right result (record no 0, 1 and 2) when I went to Page no 1? Is something wrong with the Query object?
Thanks
Raj
|