1 package org.hibernate.jdbc; 3 4 import java.sql.PreparedStatement ; 5 import java.sql.SQLException ; 6 7 import org.hibernate.HibernateException; 8 import org.hibernate.StaleStateException; 9 10 15 public class NonBatchingBatcher extends AbstractBatcher { 16 17 public NonBatchingBatcher(ConnectionManager connectionManager) { 18 super( connectionManager ); 19 } 20 21 public void addToBatch(int expectedRowCount) throws SQLException , HibernateException { 22 final int rowCount = getStatement().executeUpdate(); 23 if ( expectedRowCount>0 ) { 25 if ( expectedRowCount<rowCount ) { 26 throw new StaleStateException( 27 "Unexpected row count: " + rowCount + 28 " expected: " + expectedRowCount 29 ); 30 } 31 if ( expectedRowCount>rowCount ) { 32 throw new HibernateException( 33 "Unexpected row count: " + rowCount + 34 " expected: " + expectedRowCount 35 ); 36 } 37 } 38 } 39 40 protected void doExecuteBatch(PreparedStatement ps) throws SQLException , HibernateException { 41 } 42 43 } 44 | Popular Tags |