-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping:Same number of columns as the referenced primary key
PostPosted: Tue May 04, 2004 6:01 am 
Newbie

Joined: Tue May 04, 2004 5:51 am
Posts: 3
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>
...


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 6:03 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Stop spamming our lists and forums! Go away!

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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

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.