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?