-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: two mappings on one file with different keys
PostPosted: Mon Oct 27, 2008 10:44 am 
Newbie

Joined: Mon Oct 27, 2008 10:10 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.