public int handleBatch(final BatchInfo batchInfo) throws DAOException {
try {
this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor)
throws SQLException {
executor.startBatch();
for (BatchItem bi : batchInfo.getBatchItemList()) {
switch (batchInfo.getType()) {
case 1:
executor.insert(bi.getStatement(), bi.getObj());
break;
case 2:
executor.update(bi.getStatement(), bi.getObj());
break;
default:
executor.delete(bi.getStatement(), bi.getObj());
break;
}
}
executor.executeBatch();
return null;
}
});
return 0;
} catch (Throwable t) {
throw exceptionHandler.handleException(t);
}
}
ibatis的批量处理
最新推荐文章于 2021-02-23 17:29:41 发布