问题

我有一个JPA实体,其属性设置为

@ManyToOne
@Column(name="LicenseeFK")
private Licensee licensee;

但是当我在JBoss 6上部署时,该应用程序会抛出一个错误:

org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property

我使用Hibernate 3.5作为JPA 2.0实现。

我应该用什么来引用外键列?


#1 热门回答(221 赞)

Use@JoinColumn,代表@Column

@ManyToOne
@JoinColumn(name="LicenseeFK")
private Licensee licensee;

#2 热门回答(5 赞)

使用@JoinColumn@Column一起将导致相同的错误。将其更改为仅使用:@JoinColumn进行修复。


原文链接