diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java index 7b3233a7e..1da2b8f7c 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java @@ -269,8 +269,17 @@ public class PCDataImpl return; int index = fmd.getIndex(); + OpenJPAStateManager dsm = null; + if (sm.getPersistenceCapable().pcIsDetached()) { + dsm = (DetachedStateManager) sm.getPersistenceCapable(). + pcGetStateManager(); + sm.getPersistenceCapable().pcReplaceStateManager(sm); + } + Object val = toData(fmd, sm.fetchField(index, false), sm.getContext()); + if (dsm != null) + sm.getPersistenceCapable().pcReplaceStateManager(dsm); if (val != NULL) setData(index, val); else // unable to store field value; clear out any old values