首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring+ibatis的批量交付

2012-09-15 
spring+ibatis的批量提交public int addSendMsg(final Msg msg) {this.getSqlMapClientTemplate().execute

spring+ibatis的批量提交

public int addSendMsg(final Msg msg) {this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {public Object doInSqlMapClient(SqlMapExecutor executor)throws SQLException {executor.startBatch();int batch = 0;String[] tel_nbrs = msg.getTel_nbrs().split(",");if(tel_nbrs.length <= 0)return 0;for (int i = 0; i < tel_nbrs.length; i++) {// 参数1为:ibatis中需要执行的语句的idString content = msg.getContent();msg.setTel_nbr(tel_nbrs[i]);executor.insert("msg-info.sendMsg", msg);}executor.executeBatch();//提交return 1;}});return 1;}



热点排行