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 发布
本文介绍了一个使用SqlMapClient进行批量插入、更新和删除操作的方法。通过一个具体的Java实现案例,展示了如何根据不同的操作类型(插入、更新或删除)来执行相应的数据库操作。
1万+

被折叠的 条评论
为什么被折叠?



