Hi,
I use JPA / Hibernate 3.2.6.GA and I need to model a unidirectional oneToMany association.
Here is the mapping I wrote :
Code:
@OneToMany(targetEntity=ReponseImpl.class, cascade=CascadeType.REMOVE)
@JoinTable(
name="activite_reponse_",
joinColumns={@JoinColumn(name="activite_fk_")},
inverseJoinColumns={@JoinColumn(name="reponse_fk_", unique=true)})
public Collection<Reponse> getReponsesLibres() {
return reponsesLibres;
}
From this mapping, I expected to have a primary key in table "activite_reponse_" table composed with "activite_fk_" and "reponse_fk_" fields. But when I run hbm2ddl I have no primary key generated ... It generates the following DDL :
Code:
create table activite_reponse_ (
activite_fk_ bigint not null,
reponse_fk_ bigint not null unique,
unique (reponse_fk_)
);
alter table activite_reponse_
add index FK3F5785533876861 (activite_fk_),
add constraint FK3F5785533876861
foreign key (activite_fk_)
references activite_ (id_);
alter table activite_reponse_
add index FK3F57855664D13F9 (reponse_fk_),
add constraint FK3F57855664D13F9
foreign key (reponse_fk_)
references reponse_ (id_);
Any idea ?
Regards,
Olivier