-->
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: Getting to the bottom of Criteria and Pagination
PostPosted: Thu Jul 27, 2006 7:49 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
I have spent the best part of 3 hours this morning looking around the web, JIRA and forums, and whilst finding related topics, I have not found the definitive answer.

I have a very basic Parent 1..N Child association and I have developed a search function that allows a user to search on both parent and child properties at the same time, e.g the parent might need to be restricted to a department of say I.T, and the child's category to Hardware.

The Criteria API has been ideal for this, and I have the full querying setup. The problem is in paginating these results.

When I set a row count onto the query, Hibernate sends a big join between Parent and Child with a TOP 10 prepended to the statement. The trouble is, many of these 10 are duplicates in terms of the root entity Parent.

So I found the ResultsTransformer and by applying a distinct root entity, I can "collapse" the results down to be distinct which is great except that the list I get back from Hibernate is not 10 at all, but 4 because of this distinctifying AFTER the query.

It is this which appears to be at the heart of all the posts on this topic and no real answer exists or appears to be on the way.

I don't really want to keep querying to fill up my list of results to 10, so I am not sure what direction to take here.

Any ideas would be great.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 1:29 pm 
Beginner
Beginner

Joined: Mon Jan 24, 2005 11:33 am
Posts: 24
Location: Stuttgart, Germany
I spent a lot more time on this question and came to the same result as you did.
It's a pitty that this issue has not been resolved in the latest release (3.2.0). To me it's essential. JIRA HB-520 exists for it (http://opensource.atlassian.com/project ... wse/HB-520), but it is only minor. So there is no hope that this will be resolved soon.
However, you could vote for it.


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.