-->
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 - query - cirteria - projection
PostPosted: Thu Nov 03, 2005 6:49 pm 
Newbie

Joined: Thu May 26, 2005 6:31 pm
Posts: 19
Found this wiki page to do pagination:

http://raibledesigns.com/wiki/Wiki.jsp? ... Pagination

Query q = s.createFilter( collection, "" ); // the trivial filter
q.setMaxResults(PAGE_SIZE);
q.setFirstResult(PAGE_SIZE * pageNumber);
q.setProjection( Projections.alias( Projections.rowCount(), "numResults" ) )
List page = q.list();

The example is certainly not complete. How can I get the "numResults" out of the result? Is this one DB query or two.

The hibernate documentation also mentioned pagination:

http://www.hibernate.org/hib_docs/v3/re ... pagination

However, nothing about total result count.

Basically, what I need is two things:
1. list of the items on the page
2. total result count

Found several solutions, but none gave a complete answer. I know I should use query/criteria with projection. Please help.

I am using Hibernate 3.05


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 8:37 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Have you looked at this?
- http://forum.hibernate.org/viewtopic.php?t=939039


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.