I'm using Ibatis with Spring. I have batch inserts working after a fashion with the following method from my dao class which extends SqlMapClientDaoSupport:

   public void insertWidgets(final List<Widget> list) {
getSqlMapClientTemplate().execute(new SqlMapClientCallback() { public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
                   executor.startBatch();
                   for (Widget widget:list) {
                       executor.insert("insertWidget", widget);
                   }
                   executor.executeBatch();
                   return null;
               }
           });
}


What I want to do is to wrap that in a transaction now. I.e., start the transaction with the batch, commit it after the batch has executed. SqlMapExecutor doesn't have a startTransaction method, though.

Actually, I could do with understanding a little more just what Ibatis is doing here in terms of JDBC equivalent. Perhaps it's setting autocommit to false for the connection at the beginning of the batch anyway? Any pointers would be useful, thanks!

JM


--
==============================================
John Moore  -  Norwich, UK  -  [EMAIL PROTECTED]
==============================================

Reply via email to