Reputation: 611
My TableX has reference to TableY.
@JoinColumn(name = "idTableY", referencedColumnName = "idTableY")
@ManyToOne(optional = false, fetch=FetchType.LAZY)
private TableY idTableY;
and I get this error.
<openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.persistence.ArgumentException
"com.mycompany.entities.TableX.idTableY" has columns with targets, but OpenJPA does not support any joins on this mapping in this context.
Table Y has this code:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idTableY")
private Collection<TableX> tableXCollection;
This generated eclipse-link code is 100% normal ( all other entities/tables with similar code have no problems).
But a couple of these are giving such errors. Any idea why?
Upvotes: 3
Views: 2771
Reputation: 43
You need to add the class to the persistence.xml file.
Example:
<class> com.mycompany.entities.TableX</class>
<class> com.mycompany.entities.TableY</class>
Upvotes: 0
Reputation: 71
I got this exact error but for me the fix was to add TableY to the list of classes in the persistence unit in my persistence.xml. For me TableY was a brand new entity. I use the @JoinColumn on it and it works fine.
Upvotes: 5
Reputation: 1297
Try to remove the @JoinColumn
definition it is unnecessary. The join column containing foreign key is generated automatically. Entity is not a table those are two different things. Entity is class mapped on db table(s).
Upvotes: 4