From 1583426e01c38dd65d255a2eeb52cca475975fb7 Mon Sep 17 00:00:00 2001 From: Catalina Wei Date: Wed, 14 Jan 2009 23:21:13 +0000 Subject: [PATCH] OPENJPA-836 after em.clear the datacache is inconsistent git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@734551 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/openjpa/kernel/PCDataImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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