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) ?