ibatis的批处理
(1)spring模式:尽管spring已经配置了事务,但以下代码中还是要设置事务,不然batch不会起作用;另外这里虽然设了一下事务处理,但对全局事务并不会造成影响;
注:不启用事务将建立多次连接,这表示batch没起作用,建立事务后一次连接就搞定了.
public void batchAddExamlog(List examlogList) throws SQLException{
SqlMapClient smc=this.getSqlMapClient();
try {
smc.startTransaction();
smc.startBatch();
for (Iterator iter = examlogList.iterator(); iter.hasNext();) {
Examlog log = (Examlog) iter.next();
smc.update("insertExamlog", log);
}
smc.executeBatch();
} catch (Exception e) {
// TODO: handle exception
}finally{
smc.commitTransaction();
smc.endTransaction();
}
}
(2)直接采用回调函数设置
public void batchAddExamlog2(List examlogList){
getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
executor.update("insertSomething", "myParamValue");
executor.update("insertSomethingElse", "myOtherParamValue");
executor.executeBatch();
return null;
}
});
}
分享到:
相关推荐
ibatis批处理.doc ibatis批处理.doc
NULL 博文链接:https://san-yun.iteye.com/blog/900949
ibatis批量操作存在两种方式: 一种是直接在代码中进行循环操作,另一种是在配置文件中进行循环操作。
ibatis 完美例子 一对多 批处理 事务 和 spring struts2集成 ,一朵多 插入1万条数据,不到2秒,备注不包含类库
技术分享:ibatis的两种方式实现批处理
开发指南 iBATIS SQL Maps Page 3 of 62 Map类型的Result 复杂类型属性(即自定义类型的属性) 避免N+1 Select(1:1) 延迟加载 VS 联合查询(1:1) 复杂类型集合的属性 避免N+1 Select(1:M和M:N) 组合键值或多...
基本篇重点讲述了数据批处理的核心概念、典型的作业配置、作业步配置,以及Spring Batch框架中经典的三步走策略:数据读、数据处理和数据写,详尽地介绍了如何对CVS格式文件、JSON格式文件、XML文件、数据库和JMS...
SQL Maps (com.ibatis.sqlmap.*)......................................................................................................5 SQL Map的概念........................................................
完完全全可以用的,放心下载! 1、日期控件 ...5、jdbc 批处理 sql 6、各种数据库的分页方法 7、数据库的优化 8、海量数据的处理 9、sql 注入 10、java 设计模式 11、iBatis 使用 12、webservice 13、Hessian
使用eGovframework,maven,ibatis开发 TCP侦听器,TCP处理程序功能实现 实现专业的解析功能 响应代码,州代码设计和实施 FTP通讯功能实现 传统数据删除批处理功能的实现 常见异常功能的实现 Admin Manager的页面...
自动生成dto\dao\xml 自带批处理自动生成程序
自己整理的一位牛人写的通向架构师的道路的博文,对架构师入门很有指导意义,列出章节如下: (第一天)之Apache整合Tomcat ...(第三天)之apache性能调优 ...(第二十七天)IBM网格计算与企业批处理任务架构