Hi Sandhya, I tried your workaround, but unfortunately it didn't solve the problem:
When only managing the relation from the owning (child) side, the test runs without errors, but the child simply doesn't get merged/created during em.merge(parent). When managing the relation from the parent side (collection), the database again tries to insert NULL into the parent table. Finally, when removing the cascade from the parent (and managing the relation from both sides), I get the following exception: Exception in thread "main" <openjpa-1.0.0-r420667:568756 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Encountered new object "model.testch...@1127b52" in persistent field "model.TestParent.children<element:class model.TestChild>" of managed object "org.apache.openjpa.enhance.model$TestParent$pcsubclass-1" during attach. However, this field does not allow cascade attach. You cannot attach a reference to a new object without cascading. FailedObject: model.testch...@1127b52 Is this last exception caused by the bug OPENJPA-231 (since I'm using openjpa-1.0.0, in which this bug is not fixed)? As a new observation (following the discussion of OPENJPA-231): when I use openjpa-1.2.0 and remove the cascade from the child class, my whole testcase runs correctly! However, I'm not sure if I can get approval to use openjpa-1.2.0 within the project I'm working on. If that's the case, I'll simply switch to openjpa-1.2.0 and there's no need for a patch. If not, we need to think of another workaround... Thanks, Jonatan -- View this message in context: http://n2.nabble.com/Unexpected-merge-cascade-behavior-tp1668355p2156772.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
