Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322246

Summary: Update can be lost for untriggered LAZY xToOne with Property access and underlying variable not named same as property
Product: z_Archived Reporter: Tom Ware <tom.ware>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.orm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tom Ware CLA 2010-08-10 11:09:13 EDT
The following scenario will result in a lost update.

- Change tracking weaving is enabled
- A Lazy xToOne relationship e.g. Order - Item
- The underlying variable not named the same as the property. e.g. property name = "item", variable name = "m_item"
- Read the owning Object in a new entity manager so the valueholder representing the relationship is not triggered.  e.g. find(Order, orderPk)
- call a business method on the Owner that changes the target through the instance variable.  (i.e. business method does: m_item = new Item)
- Trigger the relationship (i.e. order.getItem().getItemId())
- flush

In this case, there will be no update.

To fix this, there are two options:

1. figure out how EclipseLink can tell if an update is required when using change tracking
2. Disable change tracking for this scenario (i.e. Use Differred Change Tracking)
Comment 1 Tom Ware CLA 2010-09-27 10:24:44 EDT
Did some investigation.  It looks like the way to fix this would be to use ASM to figure out what the underlying variable name was and then weave as though we know the variable name.

Workarounds:

1. Do not change the underlying variable when using Property Access.  Use the getter and setter methods instead.
2. Name the userlying variable the same as the property
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:06:16 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink