/**
* 批量删除
* @param statementName sql文件ID
* @param list 参数集合
*/
public void batchDelete(final String statementName, final List list) throws Exception{
if (list != null) {
this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (int i = 0, n = list.size(); i < n; i++) {
executor.delete(statementName, list.get(i));
}
executor.executeBatch();
return null;
}
});
}
}
/**
* 批量修改
* @param statementName sql文件ID
* @param list 参数集合
*/
public void batchUpdate(final String statementName, final List list) throws Exception{
if (list != null) {
this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (int i = 0, n = list.size(); i < n; i++) {
executor.update(statementName, list.get(i));
}
executor.executeBatch();
return null;
}
});
}
}
/**
* 批量添加
* @param statementName sql文件ID
* @param list 参数集合
*/
public void batchInsert(final String statementName, final List list) throws Exception{
if (list != null) {
this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (int i = 0, n = list.size(); i < n; i++) {
executor.insert(statementName, list.get(i));
}
executor.executeBatch();
return null;
}
});
}
}Ibatis批量操作
批量操作实现
最新推荐文章于 2018-07-30 00:41:50 发布
1435

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



