-->
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.  [ 4 posts ] 
Author Message
 Post subject: Criteria API - Distinct
PostPosted: Thu Nov 24, 2005 12:15 pm 
Hello!

Is there any possibility to get distinct results in the Criteria API?

like in HQL: "select distinct...."


Thanks.

Stefan


Top
  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 4:01 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Sure, with DistinctRootEntityResultTransformer:

Dim crit As ICriteria = my_session.CreateCriteria(type)
Dim A As New NHibernate.Transform.DistinctRootEntityResultTransformer
crit.SetResultTransformer(A)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 3:37 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Where does this transform the query? Database or in the app?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 9:54 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
As far as I know - the app. It would get all results 1st and then "transform" them:
Code:
DEBUG 3088 NHibernate.Transform.DistinctRootEntityResultTransformer - transformed: 5 rows to: 5 distinct results

A "select distinct" in HQL would do it in the database - it would build a distinct query in relevant dialect.


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