自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ibatis應(yīng)對批量update

開發(fā) 后端
我們在做批量update的時候,如果用for循環(huán)的話,遇到打數(shù)據(jù)量的時候效率很低。其實,ibatis里有對批量update的支持,非常好用,現(xiàn)在拿出來和大家共享。

最近遇到需要批量update數(shù)據(jù)的問題,一開始用了一個for循環(huán)去update,數(shù)據(jù)量大的時候效率很低。原因是for循環(huán)每次update一條語句,都是一次連接過程。遇到大批數(shù)據(jù)更新的時候,效率就可想而知了。在google上找了一遍,發(fā)現(xiàn)ibatis里有對批量update的支持,挺好的東西。

代碼如下:

final List tempList = list;
    try {
      if (List tempList != null) {
        template.execute(
            new SqlMapClientCallback() {
          public Object doInSqlMapClient(SqlMapExecutor executor) throws
              SQLException {
            executor.startBatch();
            for (int i = 0, n = tempList.size(); i < n; i++) {
              executor.update("test.batchupdate",(Map)tempList.get(i));
            }
            executor.executeBatch();
            return null;
          }
        }
        );
      }
    }

ibatis批量update的用法就是這么簡單,但是其工作的原理還沒搞懂,希望大家指點。

 

【編輯推薦】

  1. ibatis官方提示文檔中的錯誤
  2. ibtis配置之添加ibatis Dao支持
  3. 探索的ibatis DAO事務(wù)管理模塊
  4. ibatis DAO入門進階寶典
  5. ibtis了解iBatis.Net中的ResultMap
責(zé)任編輯:桑丘 來源: eNet硅谷動力
相關(guān)推薦

2024-09-25 08:22:06

2009-07-15 15:47:49

iBATIS是什么

2009-07-21 11:12:00

iBATIS配置

2009-07-16 09:56:32

什么是iBATIS

2009-07-15 11:43:13

<iterate>標簽

2009-07-15 17:58:07

iBATIS 動態(tài)映射

2009-07-16 10:23:30

iBATIS工作原理

2009-07-22 10:42:59

iBATIS Cach

2009-07-24 17:20:59

iBatis配置

2009-07-17 10:32:45

iBATIS MapB

2009-07-16 11:21:19

ibatis主鍵自動生成

2009-07-22 10:03:11

iBATIS Resu

2009-07-16 09:14:26

iBATIS DAO

2009-07-16 17:01:32

ibatis dao

2009-07-20 18:00:16

iBATIS DAO事

2009-09-21 16:56:14

Hibernateibatis

2009-07-15 17:19:31

iBATIS Ecli

2011-04-19 09:14:59

Ibatis

2009-07-22 16:02:14

iBATIS參數(shù)

2009-07-17 17:16:48

Spring iBAT
點贊
收藏

51CTO技術(shù)棧公眾號