nonbatchingbatcher.java
来自「hibernate-3.1.3-all-src.zip 面向对象的访问数据库工」· Java 代码 · 共 45 行
JAVA
45 行
//$Id: NonBatchingBatcher.java 8774 2005-12-06 22:27:12Z oneovthafew $
package org.hibernate.jdbc;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.StaleStateException;
/**
* An implementation of the <tt>Batcher</tt> interface that does no batching
*
* @author Gavin King
*/
public class NonBatchingBatcher extends AbstractBatcher {
public NonBatchingBatcher(ConnectionManager connectionManager, Interceptor interceptor) {
super( connectionManager, interceptor );
}
public void addToBatch(int expectedRowCount) throws SQLException, HibernateException {
final int rowCount = getStatement().executeUpdate();
//negative expected row count means we don't know how many rows to expect
if ( expectedRowCount>0 ) {
if ( expectedRowCount>rowCount ) {
throw new StaleStateException(
"Unexpected row count: " + rowCount +
" expected: " + expectedRowCount
);
}
if ( expectedRowCount<rowCount ) {
throw new HibernateException(
"Unexpected row count: " + rowCount +
" expected: " + expectedRowCount
);
}
}
}
protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?