-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping a composite-element collection with the primary key
PostPosted: Tue Nov 22, 2005 5:35 pm 
Newbie

Joined: Wed Jun 22, 2005 6:38 pm
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 5:36 pm 
Newbie

Joined: Wed Jun 22, 2005 6:38 pm
Posts: 7
Btw, the topic should have read "...WITHOUT the primary key."


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.