Can I use javax.persistence.OneToOne together with javax.persistence.ForeignKey?
annotations, hibernate, jpa
Solution
Replace
@ForeignKey(name="FK_ARTI_REPO")
By
@JoinColumn(name = "COLUMN_NAME", foreignKey = @ForeignKey(name = "FK_ARTI_REPO"))
Problem
What is wrong with the following code? What I am trying to achieve is to nail down the name of the generated foreign key. ``` @Entity public class Artifact { @Id private long id; @OneToOne(optional=false, fetch=FetchType.LAZY) @ForeignKey(name="FK_ARTI_REPO") private Repository repository; ``` But the the compilers show this error message: ``` The annotation @ForeignKey is disallowed for this location. ``` What's wrong with the code?