nonbatchingbatcher.java
来自「用Java实现的23个常用设计模式源代码」· Java 代码 · 共 38 行
JAVA
38 行
//$Id: NonBatchingBatcher.java,v 1.4.2.3 2003/08/04 11:26:46 oneovthafew Exp $package net.sf.hibernate.impl;import java.sql.PreparedStatement;import java.sql.SQLException;import net.sf.hibernate.HibernateException;import net.sf.hibernate.engine.SessionImplementor;/** * An implementation of the <tt>Batcher</tt> interface that does no batching * * @author Gavin King */public class NonBatchingBatcher extends BatcherImpl { public NonBatchingBatcher(SessionImplementor session) { super(session); } public void addToBatch(int expectedRowCount) throws SQLException, HibernateException { int rowCount = getStatement().executeUpdate(); //negative expected row count means we don't know how many rows to expect if ( expectedRowCount>0 && expectedRowCount!=rowCount ) throw new HibernateException("SQL update or deletion failed (row not found)"); } protected void doExecuteBatch(PreparedStatement ps) throws SQLException, HibernateException { } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?