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)
代码有什么问题?
更换
@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)
| 归档时间: |
|
| 查看次数: |
1562 次 |
| 最近记录: |