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.  [ 3 posts ] 
Author Message
 Post subject: my problem is how to display the results in multiple pages?
PostPosted: Wed Apr 26, 2006 9:08 pm 
Newbie

Joined: Sat Mar 18, 2006 1:27 am
Posts: 15
im new to hibernate. just wonder how to display the search result sets in multiple pages and use the hyperlinks to navigate.
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 11:39 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Use Criteria based query to get required number of records for one page. Depending on the navigation( next 10 or previous 10 ) retrieve the records by going back to the same collection query.

Code:
List objects = session.createCriteria(ReqObject.class)
     .add( Restrictions.between("propertyName", startNumber, endNumber) )
     .list();


If next link is clicked, startNumber will become (startNumber + 10), similarly endNumber. This is very simple case assuming the propertyName values are sequential incrementing. You can adjust it according to your needs.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 3:00 am 
Newbie

Joined: Tue Oct 25, 2005 6:04 am
Posts: 10
Use query.setFirstResult(int firstResult) and setMaxResults(int maxResults). This neatly translates into LIMIT firstResult, maxResults for mysql, LIMIT maxResults OFFSET firstResult for postgres or whatever way for paging your database uses.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.