Reputation: 2074
So when I run my project the User
table and the Doc
table are created, but I dont see the foreign key for User
table in the Doc
table.
As you can see I have both ManyToOne
and OneToMany
annotations, and yet the foreign key for User isn't created.
How can I solve this ?
Upvotes: 1
Views: 515
Reputation: 3943
You need to add @JoinColumn(name = "ID Column Name") annotation along with the @ManyToOne or @OneToMany annotation as ZaoTaoBao mentioned. This annotation determines the name of the column which is to be used as FK.
Refer to this link for more details: http://docs.oracle.com/javaee/6/api/javax/persistence/JoinColumn.html
Upvotes: 1