@ManyToOne 属性上不允许使用 @Column(s) [英] @Column(s) not allowed on a @ManyToOne property

查看:34
本文介绍了@ManyToOne 属性上不允许使用 @Column(s)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a JPA entity with a property set as

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

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

But when I deploy on JBoss 6 the application throws an error saying:

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

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

I use Hibernate 3.5 as the JPA 2.0 implementation.

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

What should I use to reference the foreign key column?

推荐答案

使用 @JoinColumn 而不是 @Column:

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

这篇关于@ManyToOne 属性上不允许使用 @Column(s)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆