Skip to main content



      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 16:38 Go to next message
Eclipse UserFriend
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 08:56 Go to previous messageGo to next message
Eclipse UserFriend
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.

Re: Set null causes the loading of the relationship [message #659078 is a reply to message #657623] Thu, 10 March 2011 16:47 Go to previous messageGo to next message
Eclipse UserFriend
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 13:14 Go to previous message
Eclipse UserFriend
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.
Previous Topic:How to choose sessions.xml
Next Topic:Changing container policy for toOne relationships
Goto Forum:
  


Current Time: Sun Jul 13 23:44:51 EDT 2025

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

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

Back to the top