-->
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.  [ 3 posts ] 
Author Message
 Post subject: Outer joins with ICriteria returns too many objects
PostPosted: Fri Jul 13, 2007 4:43 am 
Newbie

Joined: Tue Jun 26, 2007 7:44 am
Posts: 3
Hi,

We're currently trying to create a query object for a table that has a couple of associations. Using the ICriteria interface (actually a DetachedCriteria at first), we dynamically check if we need to add criterias for the underlying associations, and we then do it by calling a CreateCriteria on the original object, and then add our criterias from there. The SQL we get in the end looks absolutely perfect, and the returned results are correct, but it looks like Nhibernate doesn't do a correct mapping of the returned set, so we get multiple duplicate objects (one for each row in the joined result set).

We've also tried to do the same query with HQL, and have had no problems getting this to map correctly.

Btw: We have based our query code on the example found here: http://softlogger.com/5997/most-popular ... rnate.aspx

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 13, 2007 4:52 am 
Beginner
Beginner

Joined: Tue Jul 10, 2007 5:27 am
Posts: 34
Location: Belgium
try adding .SetResultTransformer(CriteriaUtil.DistinctRootEntity) to the Criteria

_________________
Davy Brion
http://ralinx.wordpress.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 13, 2007 5:10 am 
Newbie

Joined: Tue Jun 26, 2007 7:44 am
Posts: 3
That simple!

That solved it. :) Thanks a lot.


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