Community
Participate
Working Groups
Occurs only in case CloneCopyPolicy is used (default setting for propert access). CloneCopyPolicy creates a shalow clone of the original, then Eclipselink supposed to write into the copy the correct values. The new object is created and persisted in EntityManager, then its copy (created using ClonecopyPolicy is placed into shared cache). That failed at least in two cases: 1. ObjectReferenceMapping with ValueHolder. The ValueHolder on the clone is never overridden, shared with the original. 2. AggregateObjectMapping. In both cases the result is both original (in em cache) and copy (in shared cache) reference the same object.
The bug is fixed as part of Bug 307433 - Regression in Auditing Support when using defaults. (rev. 8929). Note that for verification the two tests in fieldaccess.advanced.EntityManagerJUnitTestSuite testObjectReferencedInBothEmAndSharedCache_ObjectReferenceMappingVH and testObjectReferencedInBothEmAndSharedCache_AggregateObjectMapping should be run both with fieldaccess.advanced.Employee cache settings: the setting in fieldaccess.advanced.Employee definition: @Cache( ... coordinationType=SEND_NEW_OBJECTS_WITH_CHANGES ) and alternative: @Cache( ... coordinationType=INVALIDATE_CHANGED_OBJECTS ) The fix: In ObjectReferenceMapping class, mergeChangesIntoObject method: added: // if value holder is used, then the value holder shared with original substituted for a new ValueHolder. getIndirectionPolicy().reset(target); before the last line of that method: setRealAttributeValueInObject(target, targetValueOfSource); In AggregateMapping class in both mergeChangesIntoObject and mergeIntoObject methods added additional check to an if statement: from: if (targetAggregate == null to if (targetAggregate == null || targetAggregate == sourceAggregate
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink