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/otm/core ConcreteEditingContext.java
Date Thu, 15 May 2003 21:42:21 GMT
olegnitz    2003/05/15 14:42:21

  Modified:    src/java/org/apache/ojb/otm/core ConcreteEditingContext.java
  Log:
  Turn on batch mode during commit as in ODMG
  
  Revision  Changes    Path
  1.5       +30 -14    db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java
  
  Index: ConcreteEditingContext.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/ConcreteEditingContext.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConcreteEditingContext.java	14 May 2003 22:15:37 -0000	1.4
  +++ ConcreteEditingContext.java	15 May 2003 21:42:20 -0000	1.5
  @@ -60,6 +60,7 @@
   
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
   import org.apache.ojb.otm.EditingContext;
   import org.apache.ojb.otm.OTMKit;
   import org.apache.ojb.otm.lock.LockManager;
  @@ -220,26 +221,41 @@
        */
       public void commit(OTMKit kit, PersistenceBroker pb)
       {
  +        ConnectionManagerIF connMan = pb.serviceConnectionManager();
  +        boolean saveBatchMode = connMan.isBatchMode();
           Swizzling swizzlingStrategy = kit.getSwizzlingStrategy();
   
  -        for (Iterator iterator = _order.iterator(); iterator.hasNext();)
  +        connMan.setBatchMode(true);
  +        try
           {
  -            ContextEntry entry = (ContextEntry) _objects.get(iterator.next());
  -            Object realTarget = swizzlingStrategy.getRealTarget(entry.object);
  -            State state = entry.state;
  -
  -            if (state.needsUpdate() || state.needsInsert())
  -            {
  -                pb.store(realTarget /*, state*/);
  -            }
  -            else if (state.needsDelete())
  +            for (Iterator iterator = _order.iterator(); iterator.hasNext();)
               {
  -                pb.delete(realTarget);
  +                ContextEntry entry = (ContextEntry) _objects.get(iterator.next());
  +                Object realTarget = swizzlingStrategy.getRealTarget(entry.object);
  +                State state = entry.state;
  +
  +                if (state.needsUpdate() || state.needsInsert())
  +                {
  +                    pb.store(realTarget /*, state*/);
  +                }
  +                else if (state.needsDelete())
  +                {
  +                    pb.delete(realTarget);
  +                }
  +                entry.state = state.commit();
               }
  -            entry.state = state.commit();
  +            connMan.executeBatch();
  +            _objects.clear();
  +            _order.clear();
  +        }
  +        catch (Throwable t)
  +        {
  +            connMan.clearBatch();
  +        }
  +        finally
  +        {
  +            connMan.setBatchMode(saveBatchMode);
           }
  -        _objects.clear();
  -        _order.clear();
       }
   
       /**
  
  
  

Mime
View raw message