我正在使用PlayFramework 2.4通过EBean 4连接到数据库。我遇到了一个问题,即我想将非主键加入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 doc没有谈到referencedColumnName JPA表示法 https://ebean-orm.github.io/docs#relationships
在EBean2中,似乎它将其报告为错误并已标记为已修复 http://www.avaje.org/bugdetail-263.html
所以我想问一下我的代码是否有问题?或者EBean根本不支持非PK加入?
谢谢!