A mapping like this:
static class Book {
@Id @GeneratedValue long id;
@ManyToOne
@JoinTable(name="BOOKPUBLISHER")
Publisher publisher;
}
Results in this DDL:
create table BOOKPUBLISHER (
publisher_id bigint,
id bigint not null,
primary key (id)
)
But the id column should have a unique constraint. The same issue occurs for @OneToOne, where both columns should have unique constraints, but only one unique constraint is added. |