Hi,
l am using
'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.6.Final'
The code below work ,
Code:
@ManyToMany
@JoinTable(name="biblio_author",
joinColumns=@JoinColumn(name="biblio_id"),
inverseJoinColumns=@JoinColumn(name="author_id"))
@org.hibernate.annotations.ForeignKey(name="fk_biblioauthor_biblio" , inverseName="fk_biblioauthor_author")
private Set<Author> authors = new HashSet<Author>(0);
It generated :
Code:
Hibernate: alter table biblio_author add constraint fk_biblioauthor_author foreign key (author_id) references author (id)
Hibernate: alter table biblio_author add constraint fk_biblioauthor_biblio foreign key (biblio_id) references biblio (id)
The code below don't work ,
Code:
@ManyToMany
@JoinTable(name="biblio_author",
joinColumns=@JoinColumn(name="biblio_id", foreignKey = @ForeignKey(name = "fk_biblioauthor_biblio")),
inverseJoinColumns=@JoinColumn(name="author_id" , foreignKey = @ForeignKey(name = "fk_biblioauthor_author")))
private Set<Author> authors = new HashSet<Author>(0);
It generated :
Code:
Hibernate: alter table biblio_author add constraint FK_exs5c651sjsh6gns6dxmos7dq foreign key (author_id) references author (id)
Hibernate: alter table biblio_author add constraint FK_1reuuv3csiedk2uotsklldkba foreign key (biblio_id) references biblio (id)
Thanks
Moon