-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Pagination bug in Hibernate
PostPosted: Fri Aug 15, 2008 2:00 pm 
Newbie

Joined: Fri Aug 15, 2008 1:35 pm
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 15, 2008 4:28 pm 
Newbie

Joined: Wed Aug 13, 2008 12:48 pm
Posts: 7
Location: Mérida, Yucatán, México
I try to reproduce the issue, but work fine...

can you post your code and your mapping file??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.