|Merge with Null being ignored [message #872808]
||Wed, 16 May 2012 17:36
| Mauro Flores
Registered: September 2009
When I set null to properties of an entity and call merge, the value of the column is not changed to null. If I set any other value the changing happens.|
// EJB method
Foo foo = em.find(Foo.class, 1);
Foo fooMerge = em.merge(foo);
Foo fooMerge = <call ejb method>;
System.out.println("Foo merge:" + fooMerge.getName()); // prints null
Foo fooFind = em.find(1);
System.out.println("Foo find:" + fooMerge.getName()); // prints the original value of name
This happens with an specific entity.
I can't see anything different from this entity to the others.
The field is not Transient. The merge runs inside an EJB method(CMT) running on weblogic. When I run the equivalent code standalone, the null is updated correctly.
I used to see it a lot using Openjpa implementation, but this is the first time with Eclipselink.
I appreciate some help.
[Updated on: Wed, 16 May 2012 17:40]
Report message to a moderator
|Re: Merge with Null being ignored [message #873679 is a reply to message #873584]
||Fri, 18 May 2012 16:35
| Chris Delahunt
Registered: July 2009
Do you have any settings that would cause the native query to force a refresh on Foo or any referenced objects? If so, a lazy bidirectional relationship might get traversed for the merge operation, wiping out prior changes. The fact that a cascading refresh will still occur over lazy relationships when the relationship is eventually fetched is often overlooked when using the cascade refresh/all and lazy settings. |
Unfortunately, the problem you are encountering is not going to be with what you've shown but in the settings and items that have been left out of your simple test case. I would try to pair it down to the minimum that reproduces the issue and post that if possible.
Powered by FUDForum
. Page generated in 0.02322 seconds