Hi Joey, You should always put a batch inside an explicit transaction, otherwise iBATIS will execute each statement individually. (i.e. it will ignore batch completely). That's why batchResult is empty. If you look at your database, all the updates would have happened. Try:
this.getSqlMapClient().startTransaction(); this.getSqlMapClient().startBatch(); for (Subscriber subscriber : subscriberList) { this.getSqlMapClient().update("Subscriber_updateSubscriber", subscriber); } List<BatchResult> batchResult = this.getSqlMapClient().executeBatchDetailed(); this.getSqlMapClient().commitTransaction(); Now you should see desired result. P.S.- setInBatch(false) used in executeBatchDetailed() shouldn't affect executeBatchDetailed at all. Thanks, Abhigyan Joey Lv <mrl...@gmail.com> 22/04/2009 11:10 Please respond to user-java@ibatis.apache.org To user-java@ibatis.apache.org cc Subject Question about the executeBatch...... Hi, Below is my java code, to execute a batch this.getSqlMapClient().startBatch(); for (Subscriber subscriber : subscriberList) { this.getSqlMapClient().update("Subscriber_updateSubscriber", subscriber); } List<BatchResult> batchResult = this.getSqlMapClient().executeBatchDetailed(); But I found the batchResult alway is null. Here is the source code of com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#startBatch public void startBatch(SessionScope session) { session.setInBatch(true); } and here is the source code of com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#executeBatchDetailed public List executeBatchDetailed(SessionScope session) throws SQLException, BatchException { session.setInBatch(false); return sqlExecutor.executeBatchDetailed(session); } So, why need ‘session.setInBatch(false);’ in the mehod executeBatchDetailed()? And is this the cause of "batchResult always is null"? Thanks Joey Lv