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: how does Hibernate generate query?
PostPosted: Wed Jan 26, 2011 6:29 am 
Newbie

Joined: Wed Jan 26, 2011 5:51 am
Posts: 1
I have 2 objects: User and Address, with one-to-many relation.
On the user object, the Address define as:
Code:
<set inverse="true" name="addressList" lazy="false" cascade="all-delete-orphan">
  <key column="USER_ID" />
  <one-to-many class="com.comm.it.think.user.address.AddressImpl"  not-found="ignore" />
</set>


and on the address object:
Code:
<composite-id>
<key-many-to-one column="ADDRESS_TYPE_ID" name="addressType" class="com.comm.it.think.user.address.addressType.AddressTypeImpl" lazy="false"  />
<key-many-to-one column="USER_ID" name="user" class="com.comm.it.think.user.userInfo.UserInfoImpl" lazy="false"  />
</composite-id>

the address PK is user id and address type.
when i'm trying to get the user object, i can see that hibernate generate the following query:
Code:
SELECT addresslis0_.user_id AS user2_13_1_,
       addresslis0_.address_type_id AS address1_1_,
       addresslis0_.user_id AS user2_1_,
       addresslis0_.address_type_id AS address1_27_0_,
       addresslis0_.user_id AS user2_27_0_,
       addresslis0_.address_line AS address3_27_0_,
  FROM usr_address addresslis0_
WHERE addresslis0_.user_id = ?



i'm trying to undersatnd why it add the user id and address type 3 times to the select query?


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.