Hello,

Does OpenJPA support identifying relationship (a.k.a compound identity relations) between two entities?

I checked the OpenJPA user documentation and did searches in the internet which didn't gave any good answers. So I tried to test it out my self following the bottom-up approach. I created a simple ERD (attached) with 3 entities and identifying relations between them, and used OpenJPA reverse mapping tool to generate JPA entities from the db schema. But when iI tried to persist the entities generated by the reverse-
mapping tool I get the following error:

Caused by: <openjpa-1.1.0-r422266:657916 fatal user error> org.apache.openjpa.persistence.InvalidStateException: Attempt to set column "C.B_ID" to two different values: (class java.lang.String)"B1", (null)"null" This can occur when you fail to set both sides of a two-sided relation between objects, or when you map different fields to the same column, but you do not keep the values of these fields in synch.
  at org.apache.openjpa.jdbc.sql.PrimaryRow.setObject(PrimaryRow.java:338)
  at org.apache.openjpa.jdbc.sql.RowImpl.setString(RowImpl.java:476)
  ....

Attached is the ERD that I am trying to implement using JPA.

Is identifying relations not suppored in JPA? If it is, how do I do it?

Any help is highly appreciated.

Thanks
Gopal

Reply via email to