我可以将javax.persistence.OneToOne与javax.persistence.ForeignKey一起使用吗?

use*_*051 3 annotations hibernate jpa

以下代码有什么问题?我想要实现的是确定生成的外键的名称.

@Entity
public class Artifact {
@Id private long id;
@OneToOne(optional=false, fetch=FetchType.LAZY)
@ForeignKey(name="FK_ARTI_REPO")
private Repository repository;
Run Code Online (Sandbox Code Playgroud)

但编译器显示此错误消息:

The annotation @ForeignKey is disallowed for this location.
Run Code Online (Sandbox Code Playgroud)

代码有什么问题?

SSo*_*ieb 6

更换

@ForeignKey(name="FK_ARTI_REPO")
Run Code Online (Sandbox Code Playgroud)

通过

@JoinColumn(name = "COLUMN_NAME", foreignKey = @ForeignKey(name = "FK_ARTI_REPO"))
Run Code Online (Sandbox Code Playgroud)