-->
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: paging
PostPosted: Mon Oct 10, 2005 5:37 am 
Newbie

Joined: Mon Oct 10, 2005 5:31 am
Posts: 1
how to do paging using hibernate 3.0
an example source code


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 10, 2005 9:00 am 
Newbie

Joined: Wed Aug 10, 2005 3:32 pm
Posts: 2
So far the only example of paging that I have seen is:

Query query = session.createQuery(queryStr);
query.setMaxResults(10);
query.setFirstResult(20);
return query.list();

of

Criteria crit = session.createCriteria(Foo.class);
crit.setMaxResults(10);
crit.setFirstResult(20);
return crit.list();

For max result you put in the number of objects you want returned (you can not use a fetch joining statement with paging) and for first result you put in the row number you want to start at. My only problem with this is all the examples I have seen so far pass in the page count and times it by the max size and use that as the starting point. What happens if your max result size changes? Then you can not use the page count times size. If you happen to come across a way to get the row count for an object after a sort was added please let me know.


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.