-->
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.  [ 4 posts ] 
Author Message
 Post subject: need help wth @ManyToMany between two composite PK tables
PostPosted: Wed Feb 14, 2007 11:45 am 
Beginner
Beginner

Joined: Wed Jan 31, 2007 6:54 am
Posts: 22
Hi,
I have a problem putting together the right annotation syntax for creating a manytomany relation between two tables with composite primary keys, using annotations. I want hbm2ddl to generate the required assocaition table.

Hibernate version:
3.2.2 core / 3.2.1 annotations

Table1:
NationID (PK/FK)
CityID (PK/FK)
PersonID (PK)

Table2:
NationID (PK/FK)
CityID (PK/FK)
EventID (PK) Event

So I want a association table that looks like this:
NationID(FK/PK)
CityID(FK/PK)
PersonID(FK/PK)
EventID(FK/PK)

Is this kind of relation possible using annotations? When I try I get tables like this:

Table1_NationID
Table2_NationID
Table1_CityID
Table2_CityID
PersonID
EventID

What would be the way to tell hibernate that the Nation and city ID should be the same field in the two cases, using annotations? Is it possible? Or do I need to impose some constraints?

thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 8:20 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you want to share the NATION_ID across the 2 FKs, right?
This is not yet possible, this will be possible when the port of Hibernate Core formula for join columns will be done (no target time).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 4:24 am 
Beginner
Beginner

Joined: Wed Jan 31, 2007 6:54 am
Posts: 22
Yes, that was what I wanted. Thanks for clarifying that! You mention "port of Hibernate Core formula", does this mean that this functionality is actually present in Hibernate, but only through hmb.xml mappings?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 1:59 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, <formula/> inside <key/> or <many-to-one/>
Today @Formula is only usable for regular properties

_________________
Emmanuel


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