-->
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: Criteria Distinct
PostPosted: Wed Jun 30, 2010 11:12 am 
Newbie

Joined: Thu Aug 28, 2008 6:00 am
Posts: 6
Hello, I've searched on the internet but I didn't understand very much the problem:

I'm trying to build a distinct query using criteria and a distinct clause using a projection, trying to resole the lazy attribute of the projection in the distinct.

So the query will be like this

Code:
createCriteria(Parent.class)
.setProject(Projections.distinct(Projections.properties("relation")))
.createCriteria("relation")


Unfortunately, the relation fields aren't fetched, this query return just a list of id's and I have to generate O(n) queries for fetching the results.

The equivalent in HQL would be

Code:
select distinct r from Parent as p join p.relation as r


Is it possible to do it using criteria?

I've seen that someone suggest to use the trasnformer, but I would like to use the distinct in the database.

Thank you very much

L.M.


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.