Hello,
I’ve been tasked with correcting some legacy code (Hibernate 5.2.17), but it’s solution has so far escaped me. The hibernate.config.xml references the following SidOrgRl.hbm.xml:
<?xml version="1.0"?> <class name="mil.dfas.tso.sid.domain.SidOrgRl" table="SID_ORG_RL" schema="SID_OWN"
dynamic-insert="true" dynamic-update="true" lazy="true">
<composite-id mapped="true">
<key-property name="orgDfasAsgndId" type="long">
<column name="ORG_DFAS_ASGND_ID" precision="10" scale="0" />
</key-property>
<key-property name="rlTyCd" type="string">
<column name="RL_TY_CD" length="2" />
</key-property>
</composite-id>
<many-to-one name="sidOrg" class="mil.dfas.tso.sid.domain.SidOrg" update="false" insert="false" fetch="select">
<column name="ORG_DFAS_ASGND_ID" precision="10" scale="0" not-null="true" />
</many-to-one>
</class>
If I run as is I get:
-org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/hibernate-config.xml]: Invocation of init method failed; nested exception is org.hibernate.boot.MappingException: mapped composite identifier must name component class to use. : origin(C:\Users…persistence\hibernate\mapping\SidOrgRl.hbm.xml)
or if I add class=“SidOrg” to <composite-id class=“SidOrg”… I get:
-org.springframework.beans.factory.BeanCreationException:…hibernate.boot.MappingException: Association [mil.dfas.tso.sid.domain.SidOrg.sidInfoAstOrgs] references an unmapped entity [mil.dfas.tso.sid.domain.SidOrg.sidInfoAstOrgs] : origin(C:\Users…persistence\hibernate\mapping\SidOrg.hbm.xml)
While I get the gist of the problem in that Hibernate’s not seeing a proper mapping I haven’t found anything online specifically addressing this particular composite key issue. Is it a syntax problem on my end? A 5.2.17 bug? etc.
Thanks for any insight,
Dave