-->
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.  [ 1 post ] 
Author Message
 Post subject: Pagination + Criteria API + distinctiveness
PostPosted: Fri Jan 19, 2007 3:21 pm 
Newbie

Joined: Mon Aug 28, 2006 12:01 pm
Posts: 11
I am using Criteria API for doing all the queries to the database and I need the pagination feature of Criteria API - Setting firstResult and maxResults.

All goes well until the response to the search request contains non distinct entries (I am not sure why it happens, but it does).

I filter the duplicates using Criteria.DISTINCT_ROOT_ENTITY ResultTransformer but then all the pagination logic does not apply anymore.

I searched the forum but did not find a solution to the problem (which seems trivial to me). There are workarounds such as :

http://forum.hibernate.org/viewtopic.php?t=941669&postdays=0&postorder=asc&highlight=distinctrootentity&start=0

but it does not work if I use abstract classes in my search criterias and for normal classes query cache fails with class cast exception.

Also there is an open feature request (unsolved) for several years :

http://opensource.atlassian.com/projects/hibernate/browse/HB-520

Using the projection is not handy since I need the whole object (or list of them) to be returned, and when using projection.distinct I get only the fields I specify and then the first solution fails to help due to abstract classes.

Does anyone have a solution on how can I apply distinctiveness not on the result but pass it on to SQL, to ensure proper pagination, via criteria API ? (Or implement pagination by some other means)

Thanks in advance.

Hibernate version: 3.2.1 GA


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.