Community
Participate
Working Groups
Build Identifier: 2.0.1 The join table record is not deleted for a many to many mapping when the mapping is inherited from a parent descriptor. In this case the preDeleteMapping is missing for derived ManyToManyMappings. The preDeleteMapping property is not copied from the parent in InheritancePolicy.initialize(). Reproducible: Always Steps to Reproduce: 1. Create a descriptor with a many to many mapping making sure to create the required foreign key constraints. EG Person with a many to many mapping to Address. 2. Create a descriptor that inherits from the one created in step 1. EG Employee. 3. Instantiate the child. 4. In a new transaction try to delete it. An sql exception is thrown complaining about a foreign key constraint violation as the join table record is not deleted so the employee record cannot be deleted.
Created attachment 159814 [details] Example stack trace
Created attachment 159819 [details] Proposed patch which fixes the preDeleteMapping initialization issue I actually have two patches here. The first is in InheritancePolicy.java which fixes the problem described and tested for in the unit test I've provided. The second is in ClassDescriptor.clone which also does not copy the preDeleteMappings property. I do not have a test nor a situation that proves that this is needed. I only included it for consideration.
Created attachment 159822 [details] Unit Test demonstrating many to many predelete problem Extract project, run sql script and execute MyTestSuite as a junit test.
Setting target and priority. See the following page for a description of the meanings of these values: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
EclipseLink is designed to expect you to explicitly sever relationships before you delete objects. If you want automatic deletions, there are a couple of options. 1. When using JPA API, you can set cascade options on your mappings that will allow deletes to be cascaded 2. Our private owned setting will help for some mappings.
Reopening for further investigation.
Created attachment 171746 [details] Patch with tests Reinvestigated after community request. Patch is being integrated to allow the behavior to be the same as when Inheritance is not involved.
Checked into trunk as provided Fix copies predeleteMappings when inheritance is involved Reviewed by: Tom Ware - reviewed community provided fix Added test to inheritnace test models and ran JPA and Core LRG Setting priority to P1 and target to 2.1.1 so this fix can be integrated into 2.1.1 when that stream opens
Changes have been submitted to the 2.1.1 stream.
moving ipLog to patch
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink