-->
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.  [ 6 posts ] 
Author Message
 Post subject: Pagination problem with Criteria
PostPosted: Mon Dec 06, 2004 10:32 am 
Newbie

Joined: Fri Aug 20, 2004 5:19 am
Posts: 14
Good morning

We use the pagination class Page developped by Gavin King and Eric Broyles:
on the links comments page of the web url
http://blog.hibernate.org/cgi-bin/blosx ... ation.html

This Page class uses the fact that an hibernate query can return a scrollable result set,
this is very useful to get the total number of results returned by the query
*without* to do an other query ('select count(*) from ...' ):

****
scrollableResults = query.scroll();
...
//Just retrieve from the database the elements to display in current view page
List resultsToDisplayInCurrentPage = query.setFirstResults(...).setMaxResults(...).list();
...
scrollableResults.last();
//Need to display in the current view page the total number of results returned by the query
totalResultsNumber = getScrollableResults().getRowNumber();
*****

According to the net.sf.hibernate.Criteria API, there is no method Criteria.scroll()
so the equivalent code is not possible to support pagination with Criteria query:

so is there any elegant workaround to get the total number of results with Criteria api
without doing an other query and avoiding to retrieve from the database more elements
than we need to display in the current view page?

thank you for any suggestion
F


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 12:58 pm 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
I had the very same issue with the Criteria API

See http://forum.hibernate.org/viewtopic.php?t=934828&highlight=

The Hibernate 2.1.6 Criteria API doesn't have the scroll() method but it has been added to Hibernate 3. I hope they add this method to the next Hibernate 2.x patch.

Sanjiv


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 5:21 pm 
Newbie

Joined: Fri Aug 20, 2004 5:19 am
Posts: 14
Bonjour

I add an entry for this feature request in JIRA:
http://opensource.atlassian.com/project ... se/HB-1342

please feel free to vote for me if you think like me that it would be very useful.

merci
Farid


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 5:24 pm 
Newbie

Joined: Fri Aug 20, 2004 5:19 am
Posts: 14
Oops

I made a mistake in my previous message:

you should read :

please feel free to vote for this request in Jira:
http://opensource.atlassian.com/project ... se/HB-1342

sorry
F


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 1:46 pm 
Newbie

Joined: Mon Dec 20, 2004 7:14 pm
Posts: 3
fc wrote:
Oops

I made a mistake in my previous message:

you should read :

please feel free to vote for this request in Jira:
http://opensource.atlassian.com/project ... se/HB-1342

sorry
F


Over in that request, a comment is made that there is an unofficial patch in JIRA that provides a count(), which a feature I'm interested in. Or should I just use Hibernate 3 (which I presume has this feature)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 4:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
H3 doesn't have count in criteria yet

_________________
Max
Don't forget to rate


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