-->
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: mapping and joins
PostPosted: Wed Dec 03, 2003 1:52 pm 
Newbie

Joined: Wed Dec 03, 2003 1:34 pm
Posts: 9
Can anyone spot what's wrong with this? Three tables:


<hibernate-mapping>
<class name="com.package.tableA" table="tableA" proxy="com.package.tableA" dynamic-update="false" dynamic-insert="false">
<id name="id" column="tableA_id" type="java.lang.Integer">
<generator class="assigned"></generator>
</id>
<one-to-one name="tableBLink" class="com.package.tableB" />
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="com.package.tableB" table="tableB" proxy="com.package.tableB" dynamic-update="false" dynamic-insert="false">
<id name="id" column="tableB_id" type="java.lang.Integer">
<generator class="assigned"></generator>
</id>
<one-to-one name="tableCLink" class="com.package.tableC" />
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="com.package.tableC" table="tableC" proxy="com.package.tableC" dynamic-update="false" dynamic-insert="false">
<id name="id" column="tableC_id" type="java.lang.Integer">
<generator class="assigned"></generator>
</id>
</class>
</hibernate-mapping>


and the HQL
"from tableA as A inner join fetch A.tableBLink WHERE A.tableBLink.tableCLink.id = 2"

BUT the logged SQL becomes:

select columns
.
.
.
from
tableA tableA0_ inner join tableB tableB1_ on tableA0_.id=tableB1_.id
where
(tableB1_.id=2 )


any eagle-eye hibernate techies out there who can see where the problem is coming from?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:29 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Hm... Stupid question: where is the problem?

Do you worry tableC was not joined? I suppose there is no need for this because for <one-to-one> mapping ID properties for both sides of association are equal.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
dimas wrote:
Hm... Stupid question: where is the problem?

Please stay fair, this is a beginner forum.

dimas answer is correct, however ;-). If you expect no to have the same id between A, B and C, use the property-ref attribute of one-to-one available in hibernate 2.1 to map your DB.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:48 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
"Stupid" was about MY question of course :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Sorry, I misread ;-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 5:55 am 
Newbie

Joined: Wed Dec 03, 2003 1:34 pm
Posts: 9
Ahhh! That was obvious - should have read the docs more carefully. Thanks guys.


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.