[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4024) <join>: <key>: different composite key

Sandeep Vaid (JIRA) noreply at atlassian.com
Tue Jul 7 06:43:12 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33549#action_33549 ] 

Sandeep Vaid commented on HHH-4024:
-----------------------------------

   Supose i change the above association as:
    
   <class name="BondBO" table="BOND" optimistic-lock="version" >
      <composite-id> 
       <key-property name="investmentId" column="INVESTMENTID"/>
       <key-property name="useCode" column="USECODE"/>
       <key-property name="startTime" column="STARTTIME"/>
      </composite-id>
      
      <properties name="BasicRef">
      	 <property name="investmentId" column="INVESTMENTID" insert="false" update="false"></property>
      	 <property name="startTime" column="STARTTIME" insert="false" update="false"></property>
	</properties>
	
      <version unsaved-value="undefined" name="version" column="VERSION" type="com.tietoenator.lis.common.db.Db2Timestamp" />
      
      <join table="BONDBASIC">
       <key property-ref="BasicRef"/> 
      </join>
   </class>
   
   when i try to save BondBo, It gives me that error that 
   org.hibernate.MappingException: Foreign key (FKE209E91BE94636B:PRODUCTBASIC [BondBo])) must have same number of columns as the referenced primary key (BOND [INVESTMENTID,USECODE,STARTTIME])

This limitation even with property-ref seems incorrect. Moreover there is no way to define the composite-id for BONDBASIC.

> <join>: <key>: different composite key
> --------------------------------------
>
>                 Key: HHH-4024
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4024
>             Project: Hibernate Core
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.2.6, 3.2.7, 3.3.0.CR1, 3.3.0.CR2, 3.3.0.GA, 3.3.0.SP1, 3.3.1, 3.3.2
>            Reporter: Sandeep Vaid
>            Priority: Critical
>
>  Presently hibernate doesn't support this..
>  
>  I have Bond domain class which maps to 2 tables viz. BOND nad BONDBASIC. The composite-key of both these tables are different.
>  
>  BOND -----> INVESTMENTID, USECODE, STARTTIME (as composite-key)
>  BONDBASIC ----> INVESTMENTID, INVESTMENTID2, STARTTIME, TYPE (as composite-key)
>  
>  NOTE: This is a legacy database, which i cannot change..
>  
>  In bond.hbm.xml:
>  
>  <class name="BondBO" table="TBINVESTMENTPERIOD" optimistic-lock="version" >
>    <composite-id name="compBondBO" class="CompBondBO"> 
>     <key-property name="investmentId" column="INVESTMENTID"/>
>     <key-property name="useCode" column="USECODE"/>
>     <key-property name="startTime" column="STARTTIME"/>
>    </composite-id>
>    
>    <version unsaved-value="undefined" name="version" column="VERSION" type="com.tietoenator.lis.common.db.Db2Timestamp" />
>    
>    <join table="BONDBASIC">
>     <key> 
>       <!-- <column name="INVESTMENTID"></column>-->
>       <!-- <column name="STARTTIMESTAMP"></column>-->
>      </key>
>     </join>
> </class>	 
>   How to specify the FK and PK of BONDBASIC ? 
>   Hibernate doesn't provide any way to specify this kind of mapping..

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list