openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r497185 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Wed, 17 Jan 2007 21:40:39 GMT
Author: pcl
Date: Wed Jan 17 13:40:37 2007
New Revision: 497185

URL: http://svn.apache.org/viewvc?view=rev&rev=497185
Log:
fixes for OPENJPA-102 and OPENJPA-104

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AutoDetach.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java?view=diff&rev=497185&r1=497184&r2=497185
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/AutoDetachValue.java
Wed Jan 17 13:40:37 2007
@@ -30,11 +30,13 @@
 
     public static final String DETACH_CLOSE = "close";
     public static final String DETACH_COMMIT = "commit";
+    public static final String DETACH_ROLLBACK= "rollback";
     public static final String DETACH_NONTXREAD = "nontx-read";
 
     private static String[] ALIASES = new String[]{
         DETACH_CLOSE, String.valueOf(AutoDetach.DETACH_CLOSE),
         DETACH_COMMIT, String.valueOf(AutoDetach.DETACH_COMMIT),
+        DETACH_ROLLBACK, String.valueOf(AutoDetach.DETACH_ROLLBACK),
         DETACH_NONTXREAD, String.valueOf(AutoDetach.DETACH_NONTXREAD),
         // for compatibility with JDO DetachAllOnCommit
         "true", String.valueOf(AutoDetach.DETACH_COMMIT),

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AutoDetach.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AutoDetach.java?view=diff&rev=497185&r1=497184&r2=497185
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AutoDetach.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AutoDetach.java
Wed Jan 17 13:40:37 2007
@@ -35,4 +35,9 @@
      * nontransactional operation uses a new persistence context in essence.
      */
     public static final int DETACH_NONTXREAD = 2 << 2;
+
+    /**
+     * Detach context on failed transaction commit / rollback.
+     */
+    public static final int DETACH_ROLLBACK = 2 << 3;
 }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?view=diff&rev=497185&r1=497184&r2=497185
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Wed Jan 17 13:40:37 2007
@@ -1710,7 +1710,7 @@
 
     /**
      * Mark the operation over. If outermost caller of stack, returns true
-     * and will detach manageed instances if necessary.
+     * and will detach managed instances if necessary.
      */
     public boolean endOperation() {
         try {
@@ -1779,6 +1779,10 @@
 
             if ((_autoDetach & DETACH_COMMIT) != 0)
                 detachAllInternal(null);
+            else if (status == Status.STATUS_ROLLEDBACK 
+                && (_autoDetach & DETACH_ROLLBACK) != 0) {
+                detachAllInternal(null);
+            }
 
             // in an ee context, it's possible that the user tried to close
             // us but we didn't actually close because we were waiting on this

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java?view=diff&rev=497185&r1=497184&r2=497185
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
Wed Jan 17 13:40:37 2007
@@ -40,6 +40,7 @@
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.util.CallbackException;
+import org.apache.openjpa.util.ObjectNotFoundException;
 import org.apache.openjpa.util.Proxy;
 import org.apache.openjpa.util.ProxyManager;
 import org.apache.openjpa.util.UserException;
@@ -148,7 +149,12 @@
             exclude = StoreContext.EXCLUDE_ALL;
         else if (detachMode == DETACH_ALL)
             loadMode = StateManagerImpl.LOAD_ALL;
-        sm.load(broker.getFetchConfiguration(), loadMode, exclude, null, false);
+        try {
+            sm.load(broker.getFetchConfiguration(), loadMode, exclude, null, 
+                false);
+        } catch (ObjectNotFoundException onfe) {
+            // consume the exception
+        }
 
         // create bitset of fields to detach; if mode is all we can use
         // currently loaded bitset clone, since we know all fields are loaded

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java?view=diff&rev=497185&r1=497184&r2=497185
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
Wed Jan 17 13:40:37 2007
@@ -188,7 +188,8 @@
             false);
         // we should allow the user to specify these settings in conf
         // regardless of PersistenceContextType
-        broker.setAutoDetach(AutoDetach.DETACH_CLOSE);
+        broker.setAutoDetach(AutoDetach.DETACH_CLOSE 
+            | AutoDetach.DETACH_ROLLBACK);
         broker.setDetachedNew(false);
         OpenJPAEntityManager em = newEntityManagerImpl(broker);
 



Mime
View raw message