How to name the foreign key constraint of ManyToOne references since JPA 2.1?
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"))