Hello,
I am using the latest version of hibernate and am trying to map a table with two different keys. One with an id and another with a composite id.
I get this error message :
org.hibernate.MappingException: Foreign key (FK5C6729AD57EEECA:event [userName,eventCategory])) must have same number of columns as the referenced primary key (categories [id]).
If I use two different tables it works OK.
Is there a restriction of only allowing one mapping per file, or am I missing something?
<class name="test.Category" table="categories"
lazy="true">
<cache usage="read-write" />
<id name="id" column="id" unsaved-value="null">
<generator class="uuid.hex">
</generator>
</id>
<property name="userName" column="userName">
</property>
<property name="category" column="category">
</property>
<property name="name" column="name">
</property>
.....
</class>
<class name="test.TestCategory" table="categories"
lazy="true">
<cache usage="read-write" />
<composite-id name="id"
class="test.TestCategory$Id">
<key-property name="userName" type="java.lang.String"
column="userName">
</key-property>
<key-property name="name" type="java.lang.String" column="name">
</key-property>
</composite-id>
<property name="category" column="category">
</property>
.....
</class>
Thanks in advance.
|