openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r491994 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
Date Wed, 03 Jan 2007 00:49:00 GMT
Author: awhite
Date: Tue Jan  2 16:48:59 2007
New Revision: 491994

URL: http://svn.apache.org/viewvc?view=rev&rev=491994
Log:
Exception translation when a managed transaction completion even causes an 
error.


Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java

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=491994&r1=491993&r2=491994
==============================================================================
--- 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
Tue Jan  2 16:48:59 2007
@@ -1757,11 +1757,11 @@
         } catch (OpenJPAException ke) {
             if (_log.isTraceEnabled())
                 _log.trace(_loc.get("end-trans-error"), ke);
-            throw ke;
+            throw translateManagedCompletionException(ke);
         } catch (RuntimeException re) {
             if (_log.isTraceEnabled())
                 _log.trace(_loc.get("end-trans-error"), re);
-            throw new StoreException(re);
+            throw translateManagedCompletionException(new StoreException(re));
         } finally {
             endOperation();
         }
@@ -1789,11 +1789,11 @@
         } catch (OpenJPAException ke) {
             if (_log.isTraceEnabled())
                 _log.trace(_loc.get("end-trans-error"), ke);
-            throw ke;
+            throw translateManagedCompletionException(ke);
         } catch (RuntimeException re) {
             if (_log.isTraceEnabled())
                 _log.trace(_loc.get("end-trans-error"), re);
-            throw new StoreException(re);
+            throw translateManagedCompletionException(new StoreException(re));
         } finally {
             _flags &= ~FLAG_ACTIVE;
             _flags &= ~FLAG_FLUSHED;
@@ -1811,6 +1811,15 @@
 
             endOperation();
         }
+    }
+
+    /**
+     * If we're in a managed transaction, use our implicit behavior exception
+     * translator to translate before/afterCompletion callback errors.
+     */
+    private RuntimeException translateManagedCompletionException
+        (RuntimeException re) {
+        return (!_managed || _extrans == null) ? re : _extrans.translate(re);
     }
 
     /**

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java?view=diff&rev=491994&r1=491993&r2=491994
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceExceptions.java
Tue Jan  2 16:48:59 2007
@@ -48,7 +48,7 @@
      * and {@link NonUniqueResultException} in accordance with
      * section 3.7 of the EJB 3.0 specification.
      */
-    static RuntimeExceptionTranslator getRollbackTranslator
+    public static RuntimeExceptionTranslator getRollbackTranslator
         (final OpenJPAEntityManager em) {
         return new RuntimeExceptionTranslator() {
             private boolean throwing = false;



Mime
View raw message