-->
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.  [ 1 post ] 
Author Message
 Post subject: many-to-one and resulting sql output
PostPosted: Tue Jun 23, 2009 10:34 pm 
Newbie

Joined: Tue Jun 23, 2009 9:40 pm
Posts: 1
Hi, I am new to Hibernate and puzzling over a many-to-one association mapping and the resulting sql output:

I have the following mappings:
Code:
<hibernate-mapping>
   <class name="StaffSolution" table="BK9_T_DRP_STAFF_SOLUTION">
      <!-- other properties and associations -->
      <many-to-one class="Building" column="CURRENT_BU_BLD_FK" fetch="join" lazy="false" name="currentBuilding"/>
      <many-to-one class="Employee" column="SOLUTION_OWNER_EMP_ID" fetch="join" name="solutionOwner" />
      <many-to-one class="Employee" column="SOLUTION_MAINTAIN_EMP_ID" fetch="join" name="solutionMaintainer" />
   </class>
</hibernate-mapping>

<hibernate-mapping>
   <class name="Employee" table="BK9_T_EMPLOYEE">
      <!-- other properties and associations -->
      <many-to-one class="OrganisationUnit" column="OU_PK" fetch="join" name="organisationUnit" update="false" />
      <many-to-one class="Building" column="BUILDING_PK_1" fetch="join" lazy="false" name="building" update="false" />
   </class>
</hibernate-mapping>

and the resulting sql output:
Quote:
[6/22/09 9:39:19:593 SGT] 0000002d SystemOut O Hibernate:
select ****
from
BK9_T_DRP_STAFF_SOLUTION staffsolut0_
left outer join
BK9_T_BUILDING building1_
on staffsolut0_.CURRENT_BU_BLD_FK=building1_.BUILDING_PK
left outer join
BK9_T_EMPLOYEE employee2_
on staffsolut0_.SOLUTION_OWNER_EMP_ID=employee2_.GPN
left outer join
BK9_T_OU organisati3_
on employee2_.OU_PK=organisati3_.OU_PK
left outer join
BK9_T_BUILDING building4_
on employee2_.BUILDING_PK_1=building4_.BUILDING_PK

left outer join
BK9_T_EMPLOYEE employee5_
on staffsolut0_.SOLUTION_MAINTAIN_EMP_ID=employee5_.GPN

where
staffsolut0_.PLAN_ID=?

What I don't understand is the difference of the sql joining the two BK9_T_EMPLOYEE (highlighted in blue and red), given the mappings above: why the first BK9_T_EMPLOYEE join with BK9_T_OU and BK9_T_BUILDING but the second BK9_T_EMPLOYEE does not? Can anyone help me explain that? Thank you.

Regards,
Rujing


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.