Mybatis批量更新 不同記錄,更新不同內容

2021-09-28 15:44:18 字數 1119 閱讀 6728

/**

* 為了減少效能

* 1.一次性拉取 需要同步的資料,放入記憶體中

* 2.為了防止,單次更新資料過大,分次更新;(建議一次更新100條)

*/public void syspaymenthistorydata() ", json.tojsonstring(allsyscinfo));

int totalsize = allsyscinfo.size();

int size = 100; // 每次 更新數量 100條

int fromindex = 0;

int toindex = 0;

for(fromindex = 0; fromindex < totalsize; fromindex += size)

batchupdate(allsyscinfo.sublist(fromindex, toindex));

}log.info("syspaymenthistorydata end ...");  }​

// 執行更新操作

private void batchupdate(list> sublist)

}

// 獲得需要同步的資料

list> getsyschistorypaymentinfo();

// 批量同步}

xml

select

funds.payonline_payment_funds_id as payonlinepaymentfundsid,

funds.payment_funds_code as paymentfundscode,

from

payonline_payment_funds funds,

where

and detail.payment_funds_code is null

and funds.company_code is null

order by

funds.gmt_create desc

payment_funds_code = #

總結:不建議使用方式一,當資料量大時,mysql某些版本存在bug;強烈建議使用方式二,雖然**多些,顯得相對囉唆,但是靠譜。

Mybatis批量更新

mybatis批量更新 批量操作就不進行贅述了。減少伺服器與資料庫之間的互動。網上有很多關於批量插入還有批量刪除的帖子。但是批量更新卻沒有詳細的解決方案。這裡主要講的是1張table中。根據不同的id值,來update不同的property。資料表 1張。tblsupertitleresult。錯題...

mybatis 批量更新

mybatis批量更新 批量操作就不進行贅述了。減少伺服器與資料庫之間的互動。網上有很多關於批量插入還有批量刪除的帖子。但是批量更新卻沒有詳細的解決方案。這裡主要講的是1張table中。根據不同的id值,來update不同的property。資料表 1張。tblsupertitleresult。錯題...

MyBatis批量更新

批量更新時一條記錄update一次,效能比較差,容易造成阻塞。mysql沒有提供直接的方法來實現批量更新,但可以使用case when語法來實現這個功能。update course set name case id when 1 then name1 when 2 then name2 when 3...