-->
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-join and result set
PostPosted: Thu Feb 01, 2007 8:03 pm 
Beginner
Beginner

Joined: Tue Dec 20, 2005 9:40 pm
Posts: 20
I'm not sure if this is a bug or by design, so I'm asking about it here before logging it in jira. Anyway, I have an entity with outer-join=true on a bag. In this case, my entity has three items in the bag. When I run a criteria query I get three of the same entity in my result set. I realize obviously the sql will return 3 rows, Eg.

EntityID BagItemID
1 1
1 2
1 3

But shouldn't NHib be returning just the one entity with ID 1 with a List with items BagItemID 1, 2, and 3?

Relatedly, I notice in the sql when I use a limit it's limiting on the query which does the inner join. Thus the limit is being applied to the rows returned, not the entities returned. This doesn't seem right to me.

Anyway, maybe I'll just give up using outer-join.

(I have yet to test this using projections)

So, is this how this is supposed to work?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 8:46 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Don't know how it works in NHibernate, but the equivalent in Hibernate is "criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)". Figure out how to set the result transformer on your criteria object.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject: NHibernate Solution
PostPosted: Fri Feb 02, 2007 12:48 pm 
Beginner
Beginner

Joined: Wed Nov 29, 2006 5:33 pm
Posts: 28
Location: Chicago, IL
Thanks for the pointer tenwit. I have been looking for this for a while also and your comment pointed me in the right direction. The approach in .NET is...
Code:
criteria.SetResultTransformer(New NHibernate.Transform.DistinctRootEntityResultTransformer())

Just in case it helps, we are using 1.2 Beta 3.

_________________
Chuck

Not in the face! Not in the face!


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.