Map a composite key inside a composite key hibernate xml

心已入冬 提交于 2019-12-04 16:25:12

Only one properties of the composite foreign key businessRule is included, because the <key-many-to-one only declare one column BUSINESS_RULE. It should declare the two column of the composite key it is referencing BUSINESS_RULE and ID_CD in your example. By adding the ID_CD column to the <key-many-to-one element you need to remove or rename the column of <key-property name="sameIdCode" column="ID_CD" /> element.

The association <key-many-to-one to businessRule object should be mapped like this:

<composite-id name="businessRuleObjectId" class="BusinessRuleObjectId"> 

  <key-many-to-one name="businessRule" class="BusinessRule" >
     <column name="ID_CD" />
     <column name="BUSINESS_RULE" />
  </key-many-to-one>

</composite-id> 

Hibernate reference documenation
5.1.7. composite-id
Components as composite identifiers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!