Thank you for reply Jeremy, But I think we repeat the same information we provide by creating foreignkey and adding cascade annotation from B to C if we add the cascade annotation to the back link (C to B). I opened a jira (714) to be able to clear this issue. There is also a major issue if I add the cascade annotation I get strange ID generation behavior while merging A with new added B and C objects (see jira 715 and test case).
ekin. On Wed, Jul 9, 2008 at 7:52 PM, Jeremy Bauer <[EMAIL PROTECTED]> wrote: > 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 >
