openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r934500 - in /openjpa/branches/1.2.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-persistence-jdbc/src/tes...
Date Thu, 15 Apr 2010 17:52:23 GMT
Author: mikedd
Date: Thu Apr 15 17:52:22 2010
New Revision: 934500

URL: http://svn.apache.org/viewvc?rev=934500&view=rev
Log:
OPENJPA-1550 : temporarily reverting

Removed:
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/
Modified:
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
    openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
    openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/
  (props changed)
    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-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java?rev=934500&r1=934499&r2=934500&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/BatchingPreparedStatementManagerImpl.java
Thu Apr 15 17:52:22 2010
@@ -33,7 +33,6 @@ import org.apache.openjpa.jdbc.sql.Row;
 import org.apache.openjpa.jdbc.sql.RowImpl;
 import org.apache.openjpa.jdbc.sql.SQLExceptions;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
-import org.apache.openjpa.lib.jdbc.ReportingSQLException;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.OptimisticException;
@@ -190,47 +189,15 @@ public class BatchingPreparedStatementMa
                     checkUpdateCount(rtn, batchedRowsBaseIndex, ps);
                 }
             } catch (SQLException se) {
-                //If we look at PreparedStatementManagerImpl.flushAndUpdate (which is the
'non-batch' code path
-                //similar to this path, or I should say, the path which is taken instead
of this path when
-                //we aren't using batching), we see that the catch block doesn't do a 'se.getNextException'.
-                //When we do a 'getNextException', the 'next exception' doesn't contain the
same message as se.
-                //That is, 'next exception' contains a subset msg which is contained in se.
                 SQLException sqex = se.getNextException();
-                if (sqex == null){
+                if (sqex == null)
                     sqex = se;
-                }
-                
-                if (se instanceof ReportingSQLException){
-                  int index = ((ReportingSQLException) se).getIndexOfFirstFailedObject();
-
-                  //if we have only batched one statement, the index should be 0.  As can
be seen above,
-                  //if 'batchSize == 1' a different path is taken (the 'single row' path),
and if that row
-                  //fails, we know that the index is 0 since there is only one row.
-                  if (batchSize == 1){
-                      index = 0;
-                  }
-                  
-                  //index should not be less than 0 in this path, but if for some reason
it is, lets
-                  //resort to the 'old way' and simply pass the 'ps' as the failed object.
-                  if (index < 0){ 
-                      throw SQLExceptions.getStore(se, ps, _dict);
-                  }
-                  else{
-                      throw SQLExceptions.getStore(se, ((RowImpl)(_batchedRows.get(index))).getFailedObject(),
_dict);                      
-                  }                    
-                }
-                else{
-                	//per comments above, use 'sqex' rather than 'se'. 
-                    throw SQLExceptions.getStore(sqex, ps, _dict);
-                }
+                throw SQLExceptions.getStore(sqex, ps, _dict);
             } finally {
                 _batchedSql = null;
                 batchedRows.clear();
-                
-                
                 if (ps != null) {
                     try {
-                        ps.clearParameters();
                         ps.close();
                     } catch (SQLException sqex) {
                         throw SQLExceptions.getStore(sqex, ps, _dict);

Modified: openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=934500&r1=934499&r2=934500&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Thu Apr 15 17:52:22 2010
@@ -2184,14 +2184,8 @@ public class BrokerImpl
         }
         if (opt)
             return new OptimisticException(t);
-        
-        Object failedObject = null;
-        if (t[0] instanceof OpenJPAException){
-        	failedObject = ((OpenJPAException)t[0]).getFailedObject();
-        }
-        
         return new StoreException(_loc.get("rolled-back")).
-            setNestedThrowables(t).setFatal(true).setFailedObject(failedObject);
+            setNestedThrowables(t).setFatal(true);
     }
 
     /**

Modified: openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=934500&r1=934499&r2=934500&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
(original)
+++ openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
Thu Apr 15 17:52:22 2010
@@ -66,7 +66,7 @@ public class LoggingConnectionDecorator 
     private static final int WARN_THROW = 5;
     private static final int WARN_HANDLE = 6;
     private static final String[] WARNING_ACTIONS = new String[7];
-    
+
     static {
         WARNING_ACTIONS[WARN_IGNORE] = "ignore";
         WARNING_ACTIONS[WARN_LOG_TRACE] = "trace";
@@ -183,47 +183,23 @@ public class LoggingConnectionDecorator 
         return new LoggingConnection(conn);
     }
 
-    private SQLException wrap(SQLException sqle, Statement stmnt) {
-        return wrap(sqle,stmnt,-1);        
-    }
-
     /**
      * Include SQL in exception.
      */
-    private SQLException wrap(SQLException sqle, Statement stmnt, int indexOfFailedBatchObject)
{
-        ReportingSQLException toReturn = null;
-        
+    private SQLException wrap(SQLException sqle, Statement stmnt) {
         if (sqle instanceof ReportingSQLException)
-            toReturn =  (ReportingSQLException) sqle;
-        else        
-            toReturn = new ReportingSQLException(sqle, stmnt);
-        
-        toReturn.setIndexOfFirstFailedObject(indexOfFailedBatchObject);
-        return toReturn;
+            return (ReportingSQLException) sqle;
+        return new ReportingSQLException(sqle, stmnt);
     }
 
-    private SQLException wrap(SQLException sqle, String sql) {
-        return wrap(sqle, sql,-1);
-    }
-    
     /**
      * Include SQL in exception.
      */
-    private SQLException wrap(SQLException sqle, String sql, int indexOfFailedBatchObject)
{
-        ReportingSQLException toReturn = null;
-        
-        if (sqle instanceof ReportingSQLException){
-            toReturn = (ReportingSQLException) sqle;
-        }
-        else{
-            toReturn = new ReportingSQLException(sqle, sql);
-        }
-        
-        toReturn.setIndexOfFirstFailedObject(indexOfFailedBatchObject);
-        
-        return toReturn;
+    private SQLException wrap(SQLException sqle, String sql) {
+        if (sqle instanceof ReportingSQLException)
+            return (ReportingSQLException) sqle;
+        return new ReportingSQLException(sqle, sql);
     }
-   
 
     /**
      * Interface that allows customization of what to do when
@@ -811,9 +787,6 @@ public class LoggingConnectionDecorator 
             private final String _sql;
             private List _params = null;
             private List _paramBatch = null;
-            //When batching is used, this variable contains the index into the last
-            //successfully executed batched statement.
-            int batchedRowsBaseIndex = 0;            
 
             public LoggingPreparedStatement(PreparedStatement stmnt, String sql)
                 throws SQLException {
@@ -899,45 +872,28 @@ public class LoggingConnectionDecorator 
             }
 
             public int[] executeBatch() throws SQLException {
-                int indexOfFirstFailedObject = -1;
-
                 logBatchSQL(this);
                 long start = System.currentTimeMillis();
-                try {                    
-                    int[] toReturn = super.executeBatch();
-                    //executeBatch is called any time the number of batched statements
-                    //is equal to, or less than, batchLimit.  In the 'catch' block below,

-                    //the logic seeks to find an index based on the current executeBatch

-                    //results.  This is fine when executeBatch is only called once, but 
-                    //if executeBatch is called many times, the _paramsBatch will continue

-                    //to grow, as such, to index into _paramsBatch, we need to take into

-                    //account the number of times executeBatch is called in order to 
-                    //correctly index into _paramsBatch.  To that end, each time executeBatch

-                    //is called, lets get the size of _paramBatch.  This will effectively

-                    //tell us the index of the last successfully executed batch statement.
 
-                    //If an exception is caused, then we know that _paramBatch.size was 
-                    //the index of the LAST row to successfully execute.
-                    if (_paramBatch != null){
-                        batchedRowsBaseIndex = _paramBatch.size();                      
 
-                    }
-                    return toReturn; 
+                try {
+                    return super.executeBatch();
                 } catch (SQLException se) {
                     // if the exception is a BatchUpdateException, and
                     // we are tracking parameters, then set the current
                     // parameter set to be the index of the failed
                     // statement so that the ReportingSQLException will
-                    // show the correct param(s)
+                    // show the correct param
                     if (se instanceof BatchUpdateException
                         && _paramBatch != null && shouldTrackParameters())
{
                         int[] count = ((BatchUpdateException) se).
                             getUpdateCounts();
                         if (count != null && count.length <= _paramBatch.size())
                         {
+                            int index = -1;
                             for (int i = 0; i < count.length; i++) {
                                 // -3 is Statement.STATEMENT_FAILED, but is
                                 // only available in JDK 1.4+
                                 if (count[i] == -3) {
-                                    indexOfFirstFailedObject = i;
+                                    index = i;
                                     break;
                                 }
                             }
@@ -945,34 +901,18 @@ public class LoggingConnectionDecorator 
                             // no -3 element: it may be that the server stopped
                             // processing, so the size of the count will be
                             // the index
-                            //See the Javadoc for 'getUpdateCounts'; a provider 
-                            //may stop processing when the first failure occurs, 
-                            //as such, it may only return 'UpdateCounts' for the 
-                            //first few which pass.  As such, the failed 
-                            //index is 'count.length', NOT count.length+1.  That
-                            //is, if the provider ONLY returns the first few that 
-                            //passes (i.e. say an array of [1,1] is returned) then
-                            //length is 2, and since _paramBatch starts at 0, we 
-                            //don't want to use length+1 as that will give us the 
-                            //wrong index.
-                            if (indexOfFirstFailedObject == -1){
-                                //   index = count.length + 1;
-                                indexOfFirstFailedObject = count.length;
-                            }
-                            
-                            //Finally, whatever the index is at this point, add batchedRowsBaseIndex
-                            //to it to get the final index.  Recall, we need to start our
index from the
-                            //last batch which successfully executed.
-                            indexOfFirstFailedObject += batchedRowsBaseIndex;
+                            if (index == -1)
+                                index = count.length + 1;
 
                             // set the current params to the saved values
-                            if (indexOfFirstFailedObject < _paramBatch.size())
-                                _params = (List) _paramBatch.get(indexOfFirstFailedObject);
+                            if (index < _paramBatch.size())
+                                _params = (List) _paramBatch.get(index);
                         }
                     }
-                    throw wrap(se, LoggingPreparedStatement.this, indexOfFirstFailedObject);
+                    throw wrap(se, LoggingPreparedStatement.this);
                 } finally {
                     logTime(start);
+                    clearLogParameters(true);
                     handleSQLWarning(LoggingPreparedStatement.this);
                 }
             }
@@ -1213,13 +1153,10 @@ public class LoggingConnectionDecorator 
             }
 
             private void clearLogParameters(boolean batch) {
-                if (_params != null) {
+                if (_params != null)
                     _params.clear();
-                }
-
-                if (batch && _paramBatch != null) {
+                if (batch && _paramBatch != null)
                     _paramBatch.clear();
-                }
             }
 
             private boolean shouldTrackParameters() {

Modified: openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java?rev=934500&r1=934499&r2=934500&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java
(original)
+++ openjpa/branches/1.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ReportingSQLException.java
Thu Apr 15 17:52:22 2010
@@ -32,9 +32,6 @@ public class ReportingSQLException exten
 
     private final transient Statement _stmnt;
     private final SQLException _sqle;
-    //When batching is used, and an object/row in the batch causes an exception, this
-    //variable will hold the index of the first failing object.
-    private int indexOfFirstFailedObject=-1;
 
     public ReportingSQLException(SQLException sqle, Statement stmnt,
         String sql) {
@@ -72,15 +69,7 @@ public class ReportingSQLException exten
     public Statement getStatement() {
         return _stmnt;
     }
-    
-    public int getIndexOfFirstFailedObject(){
-        return indexOfFirstFailedObject;
-    }
 
-    public void setIndexOfFirstFailedObject(int index){    
-        indexOfFirstFailedObject=index;
-    }
-    
     private static String getExceptionMessage(SQLException sqle,
         Statement stmnt, String sql) {
         try {

Propchange: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/
------------------------------------------------------------------------------
    svn:mergeinfo = 

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=934500&r1=934499&r2=934500&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 Apr 15 17:52:22 2010
@@ -62,7 +62,6 @@ 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;
@@ -521,12 +520,7 @@ 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
-            // 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);
+            throw new RollbackException(e);
         }
     }
 

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=934500&r1=934499&r2=934500&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 Apr 15 17:52:22 2010
@@ -38,8 +38,6 @@ 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;
 
@@ -69,12 +67,7 @@ public class RollbackException
     }
 
     public Object getFailedObject() {
-        return _failed;
-    }
-
-    public RollbackException setFailedObject(Object failed) {
-        _failed = failed;
-        return this;
+        return null;
     }
 
     public String toString() {



Mime
View raw message