db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/util/batch BatchConnection.java
Date Sun, 02 Nov 2003 13:21:08 GMT
olegnitz    2003/11/02 05:21:08

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionManagerIF.java ConnectionManagerImpl.java
               src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/util/batch
                        BatchConnection.java
  Log:
  Solved the problem in BatchConnection pointed out by Andy Malakov:
  executeBatch might be called automatically at improper moments causing incorrect results
  
  Revision  Changes    Path
  1.12      +6 -0      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java
  
  Index: ConnectionManagerIF.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConnectionManagerIF.java	28 Oct 2003 14:12:44 -0000	1.11
  +++ ConnectionManagerIF.java	2 Nov 2003 13:21:08 -0000	1.12
  @@ -132,6 +132,12 @@
       public void executeBatch();
   
       /**
  +     * Execute batch if the number of statements in it
  +     * exceeded the limit (if the batch mode where used).
  +     */
  +    public void executeBatchIfNecessary();
  +
  +    /**
        * Clear batch (if the batch mode where used).
        */
       public void clearBatch();
  
  
  
  1.9       +20 -1     db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java
  
  Index: ConnectionManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConnectionManagerImpl.java	28 Oct 2003 14:12:44 -0000	1.8
  +++ ConnectionManagerImpl.java	2 Nov 2003 13:21:08 -0000	1.9
  @@ -373,6 +373,25 @@
       }
   
       /**
  +     * Execute batch if the number of statements in it
  +     * exceeded the limit (if the batch mode where used).
  +     */
  +    public void executeBatchIfNecessary() throws OJBBatchUpdateException
  +    {
  +        if (batchCon != null)
  +        {
  +            try
  +            {
  +                batchCon.executeBatchIfNecessary();
  +            }
  +            catch (Throwable th)
  +            {
  +                throw new OJBBatchUpdateException(th);
  +            }
  +        }
  +    }
  +
  +    /**
        * Clear batch (if the batch mode where used).
        */
       public void clearBatch()
  
  
  
  1.45      +7 -1      db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- PersistenceBrokerImpl.java	1 Nov 2003 21:04:28 -0000	1.44
  +++ PersistenceBrokerImpl.java	2 Nov 2003 13:21:08 -0000	1.45
  @@ -454,6 +454,9 @@
               // Invoke events on PersistenceBrokerAware instances and listeners
               AFTER_DELETE_EVENT.setTarget(obj);
               fireBrokerEvent(AFTER_DELETE_EVENT);
  +            
  +            // let the connection manager to execute batch
  +            connectionManager.executeBatchIfNecessary();
           }
       }
   
  @@ -664,6 +667,9 @@
                   // now store it:
               }
               store(obj, oid, cld, doInsert);
  +            
  +            // let the connection manager to execute batch
  +            connectionManager.executeBatchIfNecessary();
           }
           // if Object == null do nothing
           else
  
  
  
  1.12      +11 -7     db-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java
  
  Index: BatchConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BatchConnection.java	27 Jun 2003 15:53:23 -0000	1.11
  +++ BatchConnection.java	2 Nov 2003 13:21:08 -0000	1.12
  @@ -159,12 +159,7 @@
       void nextExecuted(String sql) throws SQLException
       {
           count++;
  -        if (count == MAX_COUNT)
  -        {
  -            executeBatch();
  -            count = 0;
  -        }
  -
  +        
           if (_order.contains(sql))
           {
               return;
  @@ -344,6 +339,15 @@
               {
                   _deleted.clear();
               }
  +            count = 0;
  +        }
  +    }
  +
  +    public void executeBatchIfNecessary() throws SQLException
  +    {
  +        if (count >= MAX_COUNT)
  +        {
  +            executeBatch();
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message