Tak
Aug 26th, 2004, 08:59 AM
Has anyone done iBATIS 2.0 batch execution on spring before?
Looks like there is no code about it in org.springframework.orm.ibatis.SqlMapClientTemplat e in 1.1 RC2 distribution.
To do it, I am using my own classes extended spring iBatis related classes.
But if there is plan, please let me know. I don't want to use my own version for my project.
--- Here is a snippet of my codes. ---
public Object batchExecute(List parameterObject, SqlMapClientBatchExecuteCallback action) throws DataAccessException
{
SqlMapSession session = getSqlMapClient().openSession();
try {
Connection con = DataSourceUtils.getConnection(getDataSource());
try {
session.setUserConnection(con);
session.startBatch();
Iterator detailListIte = parameterObject.iterator();
while (detailListIte.hasNext()) {
Object entry = detailListIte.next();
action.doBatchInSqlMapClient(session, entry);
}
return new Integer(session.executeBatch());
} catch (SQLException ex) {
throw getExceptionTranslator().translate("SqlMapClientTemplate.batchExecute", "(mapped statement)", ex);
} finally {
DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
}
} finally {
session.close();
}
}
public Object batchInsert(final String statementName, final List parameterObject)
throws DataAccessException
{
return batchExecute(parameterObject, new SqlMapClientBatchExecuteCallback()
{
public Object doBatchInSqlMapClient(SqlMapExecutor executor, Object entry) throws SQLException
{
return executor.insert(statementName, entry);
}
});
}
public Object batchUpdate....
Regards,
Tak
Looks like there is no code about it in org.springframework.orm.ibatis.SqlMapClientTemplat e in 1.1 RC2 distribution.
To do it, I am using my own classes extended spring iBatis related classes.
But if there is plan, please let me know. I don't want to use my own version for my project.
--- Here is a snippet of my codes. ---
public Object batchExecute(List parameterObject, SqlMapClientBatchExecuteCallback action) throws DataAccessException
{
SqlMapSession session = getSqlMapClient().openSession();
try {
Connection con = DataSourceUtils.getConnection(getDataSource());
try {
session.setUserConnection(con);
session.startBatch();
Iterator detailListIte = parameterObject.iterator();
while (detailListIte.hasNext()) {
Object entry = detailListIte.next();
action.doBatchInSqlMapClient(session, entry);
}
return new Integer(session.executeBatch());
} catch (SQLException ex) {
throw getExceptionTranslator().translate("SqlMapClientTemplate.batchExecute", "(mapped statement)", ex);
} finally {
DataSourceUtils.closeConnectionIfNecessary(con, getDataSource());
}
} finally {
session.close();
}
}
public Object batchInsert(final String statementName, final List parameterObject)
throws DataAccessException
{
return batchExecute(parameterObject, new SqlMapClientBatchExecuteCallback()
{
public Object doBatchInSqlMapClient(SqlMapExecutor executor, Object entry) throws SQLException
{
return executor.insert(statementName, entry);
}
});
}
public Object batchUpdate....
Regards,
Tak