-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Batchingbatcher checkRowCounts
PostPosted: Fri Feb 06, 2009 6:14 pm 
Newbie

Joined: Fri Aug 04, 2006 3:45 pm
Posts: 4
Location: Chile
Hi all,

I'm working with a postgres partitioned database and to avoid:

Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

I'm using a implementation of AbstractBatcher that doesn't do the checkRowCounts


Code:
public class BatchingBatcherAntica extends AbstractBatcher {

   private int batchSize;
   private Expectation[] expectations;
   
   public BatchingBatcherAntica(ConnectionManager connectionManager, Interceptor interceptor) {
      super( connectionManager, interceptor );
      expectations = new Expectation[ getFactory().getSettings().getJdbcBatchSize() ];
   }

   public void addToBatch(Expectation expectation) throws SQLException, HibernateException {
      if ( !expectation.canBeBatched() ) {
         throw new HibernateException( "attempting to batch an operation which cannot be batched" );
      }
      PreparedStatement batchUpdate = getStatement();
      batchUpdate.addBatch();
      expectations[ batchSize++ ] = expectation;
      if ( batchSize == getFactory().getSettings().getJdbcBatchSize() ) {
         doExecuteBatch( batchUpdate );
      }
   }

   protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {
      if ( batchSize == 0 ) {
         //log.debug( "no batched statements to execute" );
      }
      else {

         try {
            //checkRowCounts( ps.executeBatch(), ps );
            ps.executeBatch();
         }
         catch (RuntimeException re) {
            //log.error( "Exception executing batch: ", re );
            throw re;
         }
         finally {
            batchSize = 0;
         }

      }

   }

}



I'm not sure about the consecuencies of doing this... Anyone can help me with an explanation to figure out if this is a good option or not?

What's the main propose of this function? In which cases is usless...? I looked for the hibernate javadoc but nothing is there.



Thanks in advance for any help or links


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.