openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r666512 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel: BatchingConstraintUpdateManager.java BatchingOperationOrderUpdateManager.java BatchingPreparedStatementManagerImpl.java
Date Wed, 11 Jun 2008 03:03:16 GMT
Author: fancy
Date: Tue Jun 10 20:03:16 2008
New Revision: 666512

URL: http://svn.apache.org/viewvc?rev=666512&view=rev
Log:
OPENJPA-634 Batched updates resulted in SQLException was not propagated back to users application

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingConstraintUpdateManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingOperationOrderUpdateManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingConstraintUpdateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingConstraintUpdateManager.java?rev=666512&r1=666511&r2=666512&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingConstraintUpdateManager.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingConstraintUpdateManager.java
Tue Jun 10 20:03:16 2008
@@ -19,9 +19,12 @@
 package org.apache.openjpa.jdbc.kernel;
 
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.Collection;
 
 import org.apache.openjpa.jdbc.sql.RowManager;
+import org.apache.openjpa.jdbc.sql.SQLExceptions;
+import org.apache.openjpa.util.OpenJPAException;
 
 /**
  * <P>Batch update manager that writes the SQL in object-level operation order. 
@@ -53,10 +56,24 @@
      */
     protected Collection flush(RowManager rowMgr,
         PreparedStatementManager psMgr, Collection exceps) {
-        Collection rtnCol = super.flush(rowMgr, psMgr, exceps);
+        super.flush(rowMgr, psMgr, exceps);
         BatchingPreparedStatementManagerImpl bPsMgr =
             (BatchingPreparedStatementManagerImpl) psMgr;
-        bPsMgr.flushBatch();
-        return rtnCol;
+        try {
+            bPsMgr.flushBatch();
+        } catch (SQLException se) {
+            exceps = addException(exceps, SQLExceptions.getStore(se, dict));
+        } catch (OpenJPAException ke) {
+            exceps = addException(exceps, ke);
+        }
+
+        // return all exceptions
+        Collection psExceps = psMgr.getExceptions();
+        if (exceps == null)
+            return psExceps;
+        if (psExceps == null)
+            return exceps;
+        exceps.addAll(psExceps);
+        return exceps;
     }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingOperationOrderUpdateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingOperationOrderUpdateManager.java?rev=666512&r1=666511&r2=666512&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingOperationOrderUpdateManager.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingOperationOrderUpdateManager.java
Tue Jun 10 20:03:16 2008
@@ -19,9 +19,12 @@
 package org.apache.openjpa.jdbc.kernel;
 
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.Collection;
 
 import org.apache.openjpa.jdbc.sql.RowManager;
+import org.apache.openjpa.jdbc.sql.SQLExceptions;
+import org.apache.openjpa.util.OpenJPAException;
 
 /**
  * <P>Batch update manager that writes the SQL in object-level operation order. 
@@ -55,10 +58,24 @@
      */
     protected Collection flush(RowManager rowMgr,
         PreparedStatementManager psMgr, Collection exceps) {
-        Collection rtnCol = super.flush(rowMgr, psMgr, exceps);
+        super.flush(rowMgr, psMgr, exceps);
         BatchingPreparedStatementManagerImpl bPsMgr = 
             (BatchingPreparedStatementManagerImpl) psMgr;
-        bPsMgr.flushBatch();
-        return rtnCol;
+        try {
+            bPsMgr.flushBatch();
+        } catch (SQLException se) {
+            exceps = addException(exceps, SQLExceptions.getStore(se, dict));
+        } catch (OpenJPAException ke) {
+            exceps = addException(exceps, ke);
+        }
+
+        // return all exceptions
+        Collection psExceps = psMgr.getExceptions();
+        if (exceps == null)
+            return psExceps;
+        if (psExceps == null)
+            return exceps;
+        exceps.addAll(psExceps);
+        return exceps;
     }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java?rev=666512&r1=666511&r2=666512&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
Tue Jun 10 20:03:16 2008
@@ -138,7 +138,7 @@
      * flush all cached up statements to be executed as a single or batched
      * prepared statements.
      */
-    protected void flushBatch() {
+    protected void flushBatch() throws SQLException {
         List batchedRows = getBatchedRows();
         String batchedSql = getBatchedSql();
         if (batchedRows == null)



Mime
View raw message