@org.hibernate.annotations.ForeignKey
has been deprecated, but I cannot find any examples how the JPA 2.1 equivalent would have to look like?
@ManyT
You're right, I misread the documentation. It can be defined as a part of @JoinColumn
annotation.
It should look like that:
@JoinColumn(foreignKey = @ForeignKey(name = "FK_USER"))
Do you insert @JoinColumn(foreignKey = @ForeignKey(name = "FK_USER"))
direct to mapped to entity example:
@ManyToOne
@JoinColumn(foreignKey = @ForeignKey(name = "FK_USER"))
private User user;
As the documentation indicates, this annotation can't be applied to anything:
@Target(value={})
It can thus only be used as part of another annotation (listed in the See Also section):
@JoinColumn(foreignKey = @ForeignKey(name = "FK_USER"))