-->
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.  [ 3 posts ] 
Author Message
 Post subject: Support for many-to-many with composite-ids limited?
PostPosted: Tue Dec 14, 2004 12:44 pm 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Hi,

could it be that Hibernate does not support many-to-many mappings of the following type?

I have a n-to-m relationship of objects of classes A and B. A has the following composite PK: pk1, pk2. B has the composite PK pk1, pk2, pk3. The db table for the n-to-m mapping contains pk1, pk2, pk3. So a specific combination pk1fix, pk2fix (an individual A entity) maps to corresponding combinations pk1fix, pk2fix, pk3var (the corresponding B entities).

WIth the following mapping I always get a Hibernate mapping exception. Am I correct that Hibernate does not support this type of composite PKs? (Though that would be sad, 'cause I would like to switch from JDO to Hibernate, if we don't have to change our whole DB schema.)

Mapping for A:
<set name="bs" table="AB_MAPPING" lazy="true" inverse="true">
<key>
<column name="pk1"/>
<column name="pk2"/>
</key>
<many-to-many class="B">
<column name="pk1"/>
<column name="pk2"/>
<column name="pk3"/>
</many-to-many>
</set>

Mapping for B:
<set name="as" table="AB_MAPPING" lazy="true">
<key>
<column name="pk1"/>
<column name="pk2"/>
<column name="pk3"/>
</key>
<many-to-many class="A">
<column name="pk1"/>
<column name="pk2"/>
</many-to-many>
</set>


Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 10:04 am 
Beginner
Beginner

Joined: Wed Dec 08, 2004 9:17 am
Posts: 25
Seems to be that way.
Extending the n-to-m mapping table from pk1,pk2,pk3 to pk1a,pk1b,pk2a,pk2b,pk3 did the job and since I received no response from the Hibernate team...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 10:47 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
oliver.kuntze wrote:
and since I received no response from the Hibernate team...

It has been answered many times...

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.