Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361309 - problems with updateForeignKeyFieldBeforeDelete for non-nullable fields
Summary: problems with updateForeignKeyFieldBeforeDelete for non-nullable fields
Status: CLOSED DUPLICATE of bug 341709
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-18 16:36 EDT by dsaisuresh CLA
Modified: 2022-06-09 10:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dsaisuresh CLA 2011-10-18 16:36:38 EDT
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
Comment 1 Tom Ware CLA 2011-10-19 10:33:46 EDT
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 ***
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:15:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:21:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink