ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Moore <j...@jmsd.co.uk>
Subject Batch inserts and transactions with Spring
Date Fri, 26 May 2006 10:07:10 GMT
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  -  john@jmsd.co.uk
==============================================

Mime
View raw message