Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340802 - merge problem: existing object referenced by new not cascade merged
Summary: merge problem: existing object referenced by new not cascade merged
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-23 16:22 EDT by Andrei Ilitchev CLA
Modified: 2022-06-09 10:22 EDT (History)
0 users

See Also:


Attachments
suggested patch (5.43 KB, patch)
2011-03-23 17:08 EDT, Andrei Ilitchev CLA
no flags Details | Diff
suggested patch - take 2 (6.56 KB, patch)
2011-03-23 17:15 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Ilitchev CLA 2011-03-23 16:22:01 EDT
A has OneToOne to B with cascade merge.

Create and persist a new B, close the EntityManager - the B is now detached.

Create a new A, make it reference the B, change state of the B.
Merge the A in a new EntityManager.

Result:
B is not merged - still has an old state both in cache and data base.
Comment 1 Andrei Ilitchev CLA 2011-03-23 17:08:41 EDT
Created attachment 191796 [details]
suggested patch

The patch was suggested by James: in UnitOfWorkImpl.internalRegisterObject add registeredObject to newMergedObjects only if it's a new object.
Comment 2 Andrei Ilitchev CLA 2011-03-23 17:15:33 EDT
Created attachment 191797 [details]
suggested patch - take 2

Adding a file forgotten in the first patch.
Comment 3 Andrei Ilitchev CLA 2011-03-23 17:32:54 EDT
Checked into trunk.
Added EntityManagerJUnitTestSuite.testMergeNewReferencingOldChanged
Also added testMergeNewReferencingOldChangedClearCache - for now commented out until (closely related) bug 340810 - merge problem: existing object referenced by new not cascade merged if not in cache  is fixed.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:22:46 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink