-->
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: many-to-one with composite id
PostPosted: Fri Feb 20, 2004 3:13 am 
Newbie

Joined: Fri Jan 16, 2004 4:22 am
Posts: 3
I have to map a less than normalised table structure with complex primary keys and whatnot and have run into a problem while doing this.

Say that I have these three tables:

* Table1:

Primary key: table1ID

* Table2:

Primary key (composite): table2ID, table1ID
- table1ID is a foreign key to Table1.

* Table3:

Primary key: table3ID
foreign key (composite): table2ID, table1ID

How do I express the many-to-one relationship in Table3?

The Table2 primary key mapping:

<composite-id name="table2Key" class="db.Table2Key">
<key-property name="table2ID" type="long" column="table2ID"/>
<key-many-to-one name="table1" class="db.Table1" column="table1ID"/>
</composite-id>

I've tried this for the foreign key mapping in Table3:

<many-to-one name="table2" class="db.Table2">
<column name="table2ID"/>
<column name="table1ID"/>
</many-to-one>

Which naturally won't work since the second column (table1ID) is a class reference and not a field. I can't find anything in the Hibernate manual for mapping this kind of composite foreign key.

/Bj


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 4:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It doen't work ? With what exception, log etc... ?

_________________
Emmanuel


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.