Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Set null causes the loading of the relationship
Set null causes the loading of the relationship [message #657472] Wed, 02 March 2011 21:38 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
Member
Why exactly when a lazy relationship property is set to null, the query to load that relationship is executed?

This happens just in JEE environment (weblogic 10.3.2 eclipselink 1.2.0)

Thanks. Mauro.
Re: Set null causes the loading of the relationship [message #657623 is a reply to message #657472] Thu, 03 March 2011 13:56 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Because the old value must be obtained.

To track changes and process the update correctly when you set the value of the relationship the old value must be known, to know if it changed or not. Also, if orphanRemoval is used the old value is required so it can be deleted.



James : Wiki : Book : Blog : Twitter
Re: Set null causes the loading of the relationship [message #659078 is a reply to message #657623] Thu, 10 March 2011 21:47 Go to previous messageGo to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
Member
Is there a way to change this behaviour?

Is this behaviour correct even for detached entities ?

Thanks. Mauro.
Re: Set null causes the loading of the relationship [message #660811 is a reply to message #659078] Mon, 21 March 2011 17:14 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

If you read the objects using a read-only query, then they will not track changes (but you also must not change them). You could also set "eclipselink.maintain-cache" to false on a query, this would return detached objects.

You could also create a copy of the managed object using the JpaEntityManager copy() API.

How did you detach the object? If they were copied or serialized, then they will not query the old value. If they were read from another EntityManager, then they are probably still attached to it. Technically if you closed the EntityManager, EclipseLink could be smart enough to disable change tracking, but that is not currently done, you could log a bug for that if you wish.


James : Wiki : Book : Blog : Twitter
Previous Topic:How to choose sessions.xml
Next Topic:Changing container policy for toOne relationships
Goto Forum:
  


Current Time: Fri Apr 26 12:01:30 GMT 2024

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

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

Back to the top