Strange behaviour for unidirectional 1-M associations and Association Overrides
Sorry, this is a somewhat lengthy issue but I had several problems with unidirectional 1-M associations and Association Overrides. Eventually, I could find a workaround
but it looks to me as if there are some bugs and misfits to the JPA specification in OpenJPA. Here is the story:
I get following exception using Tomee 1.6:
<openjpa-2.3.0-nonfinal-1540826-r422266:1542644 fatal user error> org.apache.openjpa.persistence.ArgumentException: You have supplied columns for "com.logitags.cibet.actuator.archive.Archive.resource.com.logitags.cibet.core.Resource.parameters",
but this mapping cannot have columns in this context.
However, the first solution using columns archiveId and
dcControllableId as foreign keys in ResourceParameter table without join table is working with Hibernate and EclipseLink, therefore I have to find a workaround for OpenJPA. The idea is to define the join table association in an orm.xml
that is only applied when using OpenJPA. As I want to replace the @JoinColumn with a @JoinTable in class Resource I have to use metadata-complete="true":
This yields the same exception as above. It seems the association-overrides in orm.xml are ignored and the annotations are used again.
Therefore I use metadata-complete="true" also for Archive and DcControllable:
At the end this works but not as expected: Instead of creating the join tables, columns archiveId and
dcControllableId in ResourceParameter table are used as foreign keys. Very strange! Does OpenJPA make an internal optimization?