5 回答

TA贡献1818条经验 获得超11个赞
要消除歧义,请使用@Column
注释:
@Column(name = "coup_id") private long coupId;
通过这种方式,您可以随意命名 Java 属性,而不用让 JPA 单独解释它们。

TA贡献1884条经验 获得超4个赞
发现问题了...抱歉。
还有另一个类Company也指的是coupId:
@OneToMany(
cascade = CascadeType.ALL,
orphanRemoval = true
)
@JoinColumn(name = "coupId")
private List<Coupon> coupons = new ArrayList();
这是来自Company班级的。

TA贡献1895条经验 获得超7个赞
我有同样的问题。
@Column(name = "coup_id") private long coupId;
和数据库表中名为 的列coup_id
。
我删除了@Column
注释,然后开始工作!就这样。
Hibernate 将 xX 转换为 x_x 本身。

TA贡献1864条经验 获得超2个赞
我遇到此问题的另一种情况是由于区分大小写。我在两个类中提到了列名称 ownerid 和 ownerId。根据错误:表 [] 包含引用多个物理列名称 [ownerid] 和 [owner_id] 的逻辑列名称 [ownerid]。我最终花了很多时间搜索 owner_id。

TA贡献1752条经验 获得超4个赞
我有连接表,它也是实体并且与两个表有 ManyToOne 关系,所以这不完全是这个问题,但可以帮助某人。
将@MapsId(
属性名称添加)
到@ManyToOne
属性对我有用。
添加回答
举报