PROBLEM DESCRIPTION
===================
I have two tables (each have composite keys). One
composit key is a subset of the other one. I get
following message error during mapping processing:
net.sf.hibernate.MappingException: Foreign key
(ROLE_ABSENCE [ABSENCETYPE_VERSIONID])) must have same
number of columns as the referenced primary key
(ABSENCETYPE [ID,VERSIONID])
at
net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:60)
at
net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:667)
at
net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:761)
at
com.test.java.dao._RootDAO.initialize(_RootDAO.java:33)
at com.test.testclient.Test.main(Test.java:14)
Has someone become a successfull mapping for a
comparable problem?
Thanks in advance!
DATABASE SCHEMA
===============
TABLE: absencetype | with composite id (id,versionid)
- id
- versionid
- column_1
- column_2
TABLE: role_absence | with composite id
(role_id,role_versionid,absencetype_id,absencetype_versionid)
- role_id
- role_versionid
- absencetype_id (foreign key to absencetype)
- absencetype_versionid (foreign key to absencetype)
- column_a
- column_b
MAPPING FILES (generated by Hibernate Synchronizer)
=============
ABSENCETYPE.hbm:
----------------
...
<class name="ABSENCETYPE" table="ABSENCETYPE">
<composite-id name="id" class="ABSENCETYPEPK">
<key-property name="id" column="ID" type="integer"/>
<key-property name="versionid" column="VERSIONID" type="integer"/>
</composite-id>
...
RoleAbsence.hbm:
----------------
...
<class name="RoleAbsence" table="ROLE_ABSENCE">
<composite-id name="id" class="RoleAbsencePK">
<key-property name="roleId" column="ROLE_ID" type="integer"/>
<key-property name="roleVersionid" column="ROLE_VERSIONID" type="integer"/>
<key-many-to-one name="absencetype" column="ABSENCETYPE_ID" class="ABSENCETYPE"/>
<key-many-to-one name="absencetypeVersionid" column="ABSENCETYPE_VERSIONID" class="ABSENCETYPE"/>
</composite-id>
...
|