-->
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: ManyToMany rel and addtional attribute in join-Table ?
PostPosted: Fri Sep 16, 2005 5:44 am 
Beginner
Beginner

Joined: Mon Sep 12, 2005 3:27 am
Posts: 48
Hello,

we have a ManyToMany problem. We want an additional attribute in the join-Table. We have "Experiments" and "Samples". Experiment can have 1 to Many Samples - and a samle can be used in 1 to Many Experiments. --> ManyToMany relationship. Additionaly we want to add to the relations-table an attribute. So we have defined 3 classes:

- experiment.class
- sample.class
- exp_sample_join.class

exp_sample_join.class defines nothing than an @id column and the additional attribute (role).
In experiment.class and sample.class we are defining the ManyToMany-Relations and define as @JOINTABLE the exp_sample_join - Table.

Now Hibernate fails on startup with failure on creating exp_sample_join - table (propably because it already exists due to defining the ManyToMany -Relation).

Code:
SCHWERWIEGEND: Unsuccessful: create table T_Exp_Sample_join (id bigint generated by default as identity (start with 1), Role VARCHAR(50) not null, primary key (id))


But how can we get the additional attribute (role) to the join-table ? And how can we prevent to have to explicit declare an @Id Column in exp_sample_join.class (there are already the joined PK from the ManyToMany-Rel-Definitions) ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use 2 bidirectional one to many between your entities and the association entity

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 1:52 pm 
Newbie

Joined: Wed Oct 12, 2005 1:47 pm
Posts: 1
I am just clarifing this...

- experiment.class
- sample.class
- exp_sample_join.class

experiment (1...n) -> exp_sample_join <- (n...1) sample


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.