Adam, Have you tried the ideas presented in that post [1] and FAQ [2]?
Greetings, Milosz [1] http://n2.nabble.com/Inconsistent-behaviour-with-Bi-directional-One-to-Many-Mapping.-tp2570464p2570464.html [2] http://openjpa.apache.org/faq.html > Hi All, > > I have played with this all day and managed to find one work-around but I > can't > really live with it for long - I hope I'm just missing something in my config > but I can't work out what: > > I have four entities, a grandparent, two parents (each with many-to-one with > the > grandparent) and one grandchild (related many-to-one to both parents). (And > all > are bi-directional). > > OpenJPA 1.2 is having problems ordering the inserts and updates when I'm > adding > new entities and seems to ignore my metadata. > > Despite setting nullable=false insertable=true updatable=false on the > grandchild > join-column definition, I see grandchild is inserted first without the parent > foreign keys and then next the parent is inserted, after which OpenJPA issues > an > UPDATE on the grandchild. This breaks the referential integrity constraints > when > the INSERT executes. > > Perhaps the cascading is important? I have tried cascading only through one > parent from grandparent to grandchild, and then through the other, and also > by > allowing both to cascade (cascade-all) but only one configuration works which > is > when I'm persisting everything. If I try it with an existing grandparent, I > can't get it to work. > > Thanks in advance for any help > > Adam > >
