ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jesse Reimann" <jreim...@ctigroup.com>
Subject RE: iBATIS Batching with Spring DAO
Date Wed, 05 Mar 2008 16:56:58 GMT
Thanks for the help. I had seen that code example before but not from
the Spring doc so didn't understand the context. After playing with it
for a bit I was able to get some test code working with the batching
using that method.

 

I don't know if it's my environment config or what but I had to make a
couple tweaks to get the example code to work

I had to make the Account final so the inner class could access it and
also have the inner class return an object.

I'm new to Java (I have a C++ and C# background) so still trying to get
a handle on the language as well as all these frameworks.

 

public class SqlMapAccountDao extends SqlMapClientDaoSupport implements
AccountDao {
 
    public void insertAccount(final Account account) throws
DataAccessException {
        getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
            public Object doInSqlMapClient(SqlMapExecutor executor)
throws SQLException {
                executor.startBatch();
                executor.update("insertAccount", account);
                executor.update("insertAddress", account.getAddress());
                return executor.executeBatch();
            }
        });
    }
}

 

 


Mime
View raw message