Hi Ekin.

I ran into a similar issue last week while using the merge operation.
I found that since I had a bi-directional relationship with unmanaged
entities (B <---> C in your case), OpenJPA needed both PERSIST and
MERGE cascade enabled in order to maintain both sides of the
relationship.  That way, new related entities can be persisted and
existing entities can be merged from either side of the relationship.
This behavior does not appear to be specifically defined by section
3.2.4.1 of the JPA spec, but it is also in my opinion, not
contradictory to the requirements which are defined.  I could be
totally off, but I was able to twist my own arm hard enough to
convince myself that OpenJPA is working as expected.  :-)

Besides adding adding the cascade options to C, if you make the B --->
C relationship uni-directional or merge B (making it managed) before
relating it to C (and vice-versa), the test also worked for me without
problems.

-Jeremy

Reply via email to