I'm trying to get a composite-element mapped to a collection via a column that is not the primary key of the containing class. The containing class has the following fragment to grab the composite-elements.
Code:
<bag name="reviews" lazy="true" order-by="ZL_MSG_ACTION_DTS" table="ZL_COMPMAIL">
<key column="ZL_MSG_ID" property-ref= />
<composite-element class="com.renewdata.odin.dao.model.ZipLipReview">
<property name="reviewee" type="java.lang.String" column="ZL_COMPMAIL_USERID"/>
<property name="reviewer" type="java.lang.String" column="ZL_REVIEWER"/>
<property name="action" type="java.lang.String" column="ZL_MSG_ACTION"/>
<property name="actionDate" type="java.util.Date" column="ZL_MSG_ACTION_DTS"/>
<property name="archiveServer" type="java.lang.String" column="ZL_MSG_ARCHIVE_SRVR"/>
</composite-element>
</bag>
Both the containing class table (ZL_MSG) and the collection table (ZL_COMPMAIL) have the column ZL_MSG_ID, with which I want to join the tables. However, the containing class does not use ZL_MSG_ID as a primary key.
Hibernate produces the correct SQL statement for this:
Code:
select reviews0_.ZL_MSG_ID as ZL1___,
reviews0_.ZL_COMPMAIL_USERID as ZL2___,
reviews0_.ZL_REVIEWER as ZL3___,
reviews0_.ZL_MSG_ACTION as ZL4___,
reviews0_.ZL_MSG_ACTION_DTS as ZL5___,
reviews0_.ZL_MSG_ARCHIVE_SRVR as ZL6___
from MIKE_ZL_COMPMAIL reviews0_
where reviews0_.ZL_MSG_ID=?
order by reviews0_.ZL_MSG_ACTION_DTS
However, I think it's using the primary key (ZL_MSG.VAULT_ID) for "ZL_MSG_ID=?", instead of ZL_MSG.ZL_MSG_ID. Is there any way to specify that Hibernate should use a different column than the primary key? I know this relational model isn't ideal but I have to work with it.
Thanks,
J