Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » delete operation not happening in child object for relationship mapping(delete operation not happening in child object)
delete operation not happening in child object for relationship mapping [message #1862701] Thu, 21 December 2023 13:49 Go to next message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
Hi Team,

As a part of migration from toplink to eclipselink , we have a case where entity in child mapping is deleted and later merge is called on parent object .Commit happens after this and can see child object is not deleted from database .
When looked into the issue , parent object still holds child in list and merges it .

please find the mapping below:

Mapping in parent table:

<attribute-mapping xsi:type="one-to-many-mapping">
<attribute-name>child</attribute-name>
<reference-class>de.*.*.*..impl.child</reference-class>
<private-owned>true</private-owned>

<cascade-persist>true</cascade-persist>

<target-foreign-key>
<field-reference>
<source-field table="child" name="MIG_ID" xsi:type="column"/>
<target-field table="Parent" name="ID" xsi:type="column"/>
</field-reference>
</target-foreign-key>
<container xsi:type="list-container-policy">
<collection-type>org.eclipse.persistence.indirection.IndirectList</collection-type>
</container>
<indirection xsi:type="transparent-collection-indirection-policy"/>
<selection-query xsi:type="read-all-query">
<container xsi:type="list-container-policy">
<collection-type>org.eclipse.persistence.indirection.IndirectList</collection-type>
</container>
</selection-query>
</attribute-mapping>

mapping in child table

<attribute-mapping xsi:type="one-to-one-mapping">
<attribute-name>migranten</attribute-name>
<reference-class>de.*.*.*.impl.MigrantenImpl</reference-class><cascade-persist>true</cascade-persist>

<foreign-key>
<field-reference>
<source-field table="child" name="MIG_ID" xsi:type="column"/>
<target-field table="parent" name="ID" xsi:type="column"/>
</field-reference>
</foreign-key>
<foreign-key-fields>
<field table="child" name="MIG_ID" xsi:type="column"/>
</foreign-key-fields>
<indirection xsi:type="value-holder-indirection-policy"/>
<selection-query xsi:type="read-object-query"/>
</attribute-mapping>

I see same happens in toplink(same mapping configuration) but it delets the child object . Could you please let me know if am missing something .

Thanks,
Sanjana

[Updated on: Thu, 21 December 2023 13:50]

Report message to a moderator

Re: delete operation not happening in child object for relationship mapping [message #1862752 is a reply to message #1862701] Wed, 27 December 2023 16:14 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 54
Registered: December 2021
Member
This is expected behavior, and I would consider it a bug in the earlier TopLink code base. Merging in an entity with references to a previously deleted entity should always be expected to undo or insert the previously deleted child entity.

Best option is always to fix/null all references to objects you are deleting and ensure all cached references are cleaned up.
Re: delete operation not happening in child object for relationship mapping [message #1862773 is a reply to message #1862752] Fri, 29 December 2023 05:49 Go to previous message
Sanjana C is currently offline Sanjana CFriend
Messages: 31
Registered: December 2022
Member
Thanks Chris for the reply .
Previous Topic:Embedded Persistence Issue
Next Topic:Deletion of entity throwing foreign key constraint for unidirectional mapping
Goto Forum:
  


Current Time: Sat Apr 27 18:27:15 GMT 2024

Powered by FUDForum. Page generated in 0.03357 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top