I am using PlayFramework 2.4 to connect to DB by EBean 4. I face a problem which is I would like to join 2 table with non primary key as follow and using referencedColumnName to map ColA with 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;
But it return the following error:
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?
I find that EBean4 doc did not talk about the referencedColumnName JPA notation https://ebean-orm.github.io/docs#relationships
And in EBean2, it seems it report it as a bug and marked fixed already http://www.avaje.org/bugdetail-263.html
So I would like to ask is my code has problem? Or EBean did not support join by the Non-PK at all?
Thanks!