iBATIS批量操作
其中statementName為sql文件ID,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;
}
});
}
}
// 批量修改
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;
}
});
}
}
// 批量添加
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;
}
});
}
}
原帖地址:https://blog.csdn.net/xinghui_liu/article/details/7230400
最後更新:2017-04-03 16:49:26
上一篇:
Hibernate聯合主鍵
下一篇:
java中的this關鍵字
類加載與 Java主類加載機製解析
案例 | 病理“數字化”,Proscia 用 AI 提升病理診斷精確度
ASP.NET MVC的客戶端驗證:jQuery驗證在Model驗證中的實現
poj 2247 Humble Numbers
[Hadoop係列]Hadoop的安裝-3.完全分布模式
Javascript編程“陷阱”總結
用戶為什麼卸載你的應用?
【曹操】【js-sequence-diagrams】前端js繪製時序圖
新車下線,小鵬汽車高速增長:每月至少一名高管加入,同步進行三輪融資
HTTP的請求頭 Last-Modified 與 If-Modified-Since 和 If-None-Match 與 ETags