0

我正在使用 PlayFramework 2.4 通过 EBean 4 连接到 DB。我面临一个问题,我想加入 2 个具有非主键的表,如下所示,并使用 referencedColumnName 将 ColA 与 ColB 映射。

Table_1                   Table_2
----------                ----------
Id_T1(PK)                 Id_T2(PK)
ColA------(OneToMany)-----ColB
...                       ...

Table_1.java
@OneToMany(mappedBy="table1")
private List<Table_2> table2s;

Table_2.java
@ManyToOne
@JoinColumn(name="ColA", referencedColumnName="ColB")  
private Table_1 table1;

但它返回以下错误:

Error injecting constructor, javax.persistence.PersistenceException: Error with the Join on [models.Table_1.table2s]. Could not find the matching foreign key for [itemUID] in table[Table_2]? Perhaps using a @JoinColumn with the name/referencedColumnName attributes swapped?

我发现 EBean4 文档没有谈论 referencedColumnName JPA 符号 https://ebean-orm.github.io/docs#relationships

在 EBean2 中,它似乎将其报告为错误并标记为已修复 http://www.avaje.org/bugdetail-263.html

所以我想问一下我的代码有问题吗?还是EBean根本不支持非PK加入?

谢谢!

4

0 回答 0