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: join on the same table twice in a query
PostPosted: Mon Apr 14, 2008 2:21 pm 
Newbie

Joined: Wed Feb 06, 2008 3:43 pm
Posts: 5
Hi,

I'm wondering if there is way to join on the same table twice in a query ?

SELECT t1, t2, t3, t4, t5, t6, t7, t8
FROM
TbCollection AS t1,
TbObject AS t2
LEFT outer JOIN t2.stringValues as t3 with t3.AttributesId = 1
LEFT outer JOIN t2.stringValues as t4 with t4.AttributesId = 2
LEFT outer JOIN t2.dateValues as t5 with t5.AttributesId = 3
LEFT outer JOIN t2.stringValues as t6 with t6.AttributesId = 4
LEFT outer JOIN t2.stringValues as t7 with t7.AttributesId = 5
LEFT outer JOIN t2.stringValues as t8 with t8.AttributesId= 6
where t1.CollectionId = t2.CollectionId AND t1.DomaineCode = 123

<bag name="stringValues" table="tb_attributes_string" lazy="false">
<key column="OBJECT_ID" />
<one-to-many class="persistance.TbAttributesString" />
</bag>

Because i'm having a problem, elements from the same table have the same instance.

regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 14, 2008 4:18 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
There shouldn't be any problem joining twice to the same table. However, you will likely encounter problems with the left outer join; see http://jira.nhibernate.org:8080/jira/browse/NH-514


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 14, 2008 9:22 pm 
Newbie

Joined: Wed Feb 06, 2008 3:43 pm
Posts: 5
I think the problem with left outter has been solved with implementation of the "with" statement since Hibernate 3.0.

But my problem isn't the join statement. My problem is the following: when I go through my object list, I always have the same object reference for each data from the same table. But the generated SQL is good I tested it in SQL plus.

I don't know why there is not different object for each join statement.

thank


Top
 Profile  
 
 Post subject: join on the same table twice in a query
PostPosted: Tue Apr 15, 2008 5:16 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

Perhaps I've misunderstood the problem, but I believe that is correct behaviour. NHibernate's identity map will ensure that there is only one instance of a given type with a given identifier.

Regards,
Richard


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.