Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » unexpected behavior using refreshAndLockObject (refreshAndLockObject does not work with Indirection)
unexpected behavior using refreshAndLockObject [message #639324] Tue, 16 November 2010 05:34 Go to next message
Tony Oganesian is currently offline Tony OganesianFriend
Messages: 9
Registered: July 2009
Junior Member
I came across a strange case today which seems worth sharing with the community. I would greatly appreciate any feedback and comments to help explain this behavior

Setup
LabOrder (1 - many) LabTestResult [using transparent indirection]
LabTestResult (1 - 1) LabOrder [using ValueHolder]

Case

// LabTestResult labTestResult was previously read from the session

UnitOfWork uow = session.acquireUnitOfWork();
LabTestResult ltr_clone = (LabTestResult) uow.refreshAndLockObject(labTestResult);
System.out.println(ltr_clone.getEdiUpdate()); // This prints NULL which is the current value in the DB

ltr_clone.setEdiUpdate(dt);
System.out.println(ltr_clone.getEdiUpdate()); // This prints dt which was just set

ltr_clone.getLabOrder().getLabTestResultSet().size();
System.out.println(ltr_clone.getEdiUpdate()); // This prints NULL [why?]

uow.commit(); // Finds nothing to commit


Question is why EL is refreshing the contents of the ltr_clone while executing the transparent indirection query?
Re: unexpected behavior using refreshAndLockObject [message #639422 is a reply to message #639324] Tue, 16 November 2010 13:52 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

This is the result of the refresh cascading over references. This should only occur though if a relationship is privately owned, as the refreshAndLockObject method marks the query's cascade value to CascadePrivateParts.

Do you have both relationships marked as privately owned? You should make one of them owned by the other, not both.

Best Regards,
Chris
Re: unexpected behavior using refreshAndLockObject [message #639616 is a reply to message #639422] Wed, 17 November 2010 08:26 Go to previous message
Tony Oganesian is currently offline Tony OganesianFriend
Messages: 9
Registered: July 2009
Junior Member
Chris,

Thank you for looking into this!

Only one of the relationships is privately owned.

LabOrder (1 - many) LabTestResult [using transparent indirection] [privately owned]

Would that still explain the behavior?

Tony
Previous Topic:[EclipseLink 2.1.1 / SDO] DataGraph Support
Next Topic:Null Property persisted with value Zero
Goto Forum:
  


Current Time: Thu Nov 27 21:09:39 GMT 2014

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

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