openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1303508 - in /openjpa/branches/2.2.x: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java
Date Wed, 21 Mar 2012 19:08:28 GMT
Author: curtisr7
Date: Wed Mar 21 19:08:28 2012
New Revision: 1303508

URL: http://svn.apache.org/viewvc?rev=1303508&view=rev
Log:
OPENJPA-2158: Null out StateManager when lite auto detaching proxies.

Modified:
    openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java

Modified: openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java?rev=1303508&r1=1303507&r2=1303508&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java
(original)
+++ openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManagerLite.java
Wed Mar 21 19:08:28 2012
@@ -81,13 +81,15 @@ public class DetachManagerLite {
             // need to null out LRS fields.
             nullField(fieldIndex, pc, sm, fm);
         } else {
-            if (!_detachProxies) {
-                return;
-            }
             Object o = sm.fetchObject(fieldIndex);
             if (o instanceof Proxy) {
                 // Get unproxied object and replace
                 Proxy proxy = (Proxy) o;
+                if (!_detachProxies) {
+                    // Even if we're not detaching proxies, we need to remove the reference
to the SM.
+                    proxy.setOwner(null, -1);
+                    return;
+                }
                 Object unproxied = proxy.copy(proxy);
                 fm.storeObjectField(fieldIndex, unproxied);
                 sm.replaceField(pc, fm, fieldIndex);

Modified: openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java?rev=1303508&r1=1303507&r2=1303508&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java
(original)
+++ openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachLite.java
Wed Mar 21 19:08:28 2012
@@ -76,6 +76,9 @@ public class TestDetachLite extends Test
 
                 assertTrue(beforeDetachCal instanceof Proxy);
                 assertTrue(afterDetachCal instanceof Proxy);
+                
+                // Make sure that we get rid of the StateManager.
+                assertNull(((Proxy)afterDetachCal).getOwner());
             } finally {
                 if (iem.getTransaction().isActive()) {
                     iem.getTransaction().rollback();



Mime
View raw message