openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Logemann ...@logemann.org>
Subject update null relation on merge()
Date Fri, 24 Aug 2012 09:16:32 GMT
Hi,

i am facing something like described here:

http://openjpa.208410.n2.nabble.com/null-values-not-updating-td3224059.html

We get a JSON graph from frontend, let Spring deserialize it to a java object (with OID set)
and want to change the existing object in the db. This works for simple attribtues likes Strings
and so but not for 1:1 relations. If we set it to "null" in the frontend, we want to change
the 1:1 relation to null. Instead it leaves the 1:1 relations untouched with the old object
reference in it. 

The OpenJPA docs once said: "When attaching null fields in these cases, OpenJPA cannot distinguish
between a field that was unloaded and one that was intentionally set to null. In this case,
OpenJPA will use the current detach state setting to determine how to handle null fields:
fields that would have been included in the detached state are treated as loaded, and will
in turn set the corresponding attached field to null."

At this point i dont know what to do. Spring knows its detached because we submit our @Id
Field => OID with a valid and existant value but the merge itself just ignores null values
for 1:1 relations and leaves them as they were. Is there any sensible way to tell OpenJPA
to merge "null" relations differently?

---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de





Mime
View raw message