Community
Participate
Working Groups
Build Identifier: eclipselink 2.3 With the latest eclipselink 2.3 release, foreign keys are nulled when a dependency cycle is identified during an object deletion(@see DeleteObjectQuery.executeDatabaseQuery). This will throw a InvalidSQLException if there is a NOT NULL constraint defined on the database column. Reproducible: Always Steps to Reproduce: pseudo code setup: class A { descriptor(TABLE_A) primaryKey_A } class B { descriptor(TABLE_B) ForeignKey_B references primaryKey_A NOT NULL } pseudo code test: A a B b b.setA(a) commit delete(a) delete(b) commit
I believe this is a duplicate of bug 341709. Please vote for that bug if it is important to you. That bug has a fairly long discussion in it, so here is a summary. This occurs when you have a cycle of mappings. e.g. A maps to B with a foreign key on the A table and B maps to A with a foreign key on the B table. In that situation, in order to delete without a foreign key violation, we have to null out one of those relationships - that's why you see the update statement. There are several ways you can deal with this issue. 1. Remove the NOT NULL constraint 2. Add a constraint dependency - some discussion in the referenced bug 3. If your database supports deferral of the NOT NULL constraint, defer it to commit 4. Remove the cycle either my severing the mappings or redesigning how your foreign keys are distributed Note: When the referenced issue is addressed, the change will likely require deferring your foreign key constraint checks to commit (much like #3 above) *** This bug has been marked as a duplicate of bug 341709 ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink