openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r927262 - in /openjpa/branches/1.2.x: openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Thu, 25 Mar 2010 03:19:05 GMT
Author: mikedd
Date: Thu Mar 25 03:19:03 2010
New Revision: 927262

URL: http://svn.apache.org/viewvc?rev=927262&view=rev
Log:
OPENJPA-1550:
Set failedObject on RollbackException.
Submitted By: Heath Thomann

Modified:
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
    openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
    openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RollbackException.java

Modified: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java?rev=927262&r1=927261&r2=927262&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
(original)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
Thu Mar 25 03:19:03 2010
@@ -285,11 +285,10 @@ public class TestBatchLimitException ext
     // Verify that the resultant exception contains the correct 'failed object'
     // and exception message.
     public void verifyExDetails(Throwable excp) throws Throwable {
-        // The cause should contain the 'failed object'
-        Throwable cause = excp.getCause();
-        verifyFailedObject(cause);
+        // The exception should contain the 'failed object'
+        verifyFailedObject(excp);
         // The second cause should contain the message which shows the failing prepared statement.
-        cause = cause.getCause();
+        Throwable cause = excp.getCause().getCause();
         verifyExMsg(cause.getMessage());
     }
 

Modified: openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?rev=927262&r1=927261&r2=927262&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
(original)
+++ openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
Thu Mar 25 03:19:03 2010
@@ -62,6 +62,7 @@ import org.apache.openjpa.meta.ClassMeta
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.QueryMetaData;
 import org.apache.openjpa.meta.SequenceMetaData;
+import org.apache.openjpa.util.ExceptionInfo;
 import org.apache.openjpa.util.Exceptions;
 import org.apache.openjpa.util.ImplHelper;
 import org.apache.openjpa.util.RuntimeExceptionTranslator;
@@ -520,7 +521,12 @@ public class EntityManagerImpl
             // should be thrown whenever the commit fails for any reason at
             // all, wheras the exception translator handles exceptions that
             // are caused for specific reasons
-            throw new RollbackException(e);
+            // pass along the failed object if one is available.
+            Object failedObject = null;
+            if (e instanceof ExceptionInfo) {
+                failedObject = ((ExceptionInfo) e).getFailedObject();
+            }
+            throw new RollbackException(e).setFailedObject(failedObject);
         }
     }
 

Modified: openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RollbackException.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RollbackException.java?rev=927262&r1=927261&r2=927262&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RollbackException.java
(original)
+++ openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/RollbackException.java
Thu Mar 25 03:19:03 2010
@@ -38,6 +38,8 @@ import org.apache.openjpa.util.Exception
 public class RollbackException
     extends javax.persistence.RollbackException
     implements Serializable, ExceptionInfo {
+	
+    private transient Object _failed = null;
 
     private transient Throwable[] _nested;
 
@@ -67,7 +69,12 @@ public class RollbackException
     }
 
     public Object getFailedObject() {
-        return null;
+        return _failed;
+    }
+
+    public RollbackException setFailedObject(Object failed) {
+        _failed = failed;
+        return this;
     }
 
     public String toString() {



Mime
View raw message