-->
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: Criteria + order distinct
PostPosted: Mon Nov 22, 2004 11:12 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Hi all,

I only want to know something about distinct with criteria. I saw that an implementation of distinct might be developped for Criteria and I want to know if it's released in the last version of Hibernate?
Sorry if this question is already answered but I only found old post about this subject.
Thanks in advance.

kind regards.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 1:53 pm 
Newbie

Joined: Tue Sep 21, 2004 6:10 pm
Posts: 16
Location: Toronto, Canada
I am using hibernate-3.1beta1 and it already have a Projections.distinct(myprojection).

Hope it helps..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:14 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
edovale wrote:
I am using hibernate-3.1beta1 and it already have a Projections.distinct(myprojection).


I think the projection stuff only happens after all the results are queried from the database

for example
Code:
createCriteria(Some.class).setProjection(Projections.distinct(myprojection)).setMaxResults(20);


if the first 15 items were the same, you'd get 6 items back, instead of 20 distinct items from the db

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:18 pm 
Newbie

Joined: Tue Sep 21, 2004 6:10 pm
Posts: 16
Location: Toronto, Canada
kochcp wrote:
edovale wrote:
I am using hibernate-3.1beta1 and it already have a Projections.distinct(myprojection).


I think the projection stuff only happens after all the results are queried from the database



I don't think so. The projections actually affect the generated sql statement.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:22 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
edovale wrote:


I don't think so. The projections actually affect the generated sql statement.[/quote]

hmm, maybe I am thinking of setResultTransformer

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:33 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
yeah, edovale is right, that puts distinct in the generated sql

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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.