mybatis?foreach傳兩個參數(shù)批量刪除
需求
foreach中要傳兩個參數(shù),一個是id,一個是list。怎么傳呢?
單list的情況
Mapper.java
/**
* 批量刪除
* @param teamList
* @return
*/
public int batchDeleteBizTeam(List<BizTeam> teamList);Mapper.xml
<delete id="batchDeleteBizTeam">
delete from biz_team where id in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item.id}
</foreach>
</delete>因為我們只傳了一個參數(shù),所以這里的collection="list"會自動對應(yīng)List teamList
多參數(shù)+list用map傳參
傳參地方:
Map params = new HashMap();
params.put("matchId", matchIdLong);
params.put("oeList", oddsEuropeList)Mapper.java
/**
* 批量刪除數(shù)據(jù)
* @param params
* @return
*/
public int batchDeleteOddsEurope(Map params);Mapper.xml
<delete id="batchDeleteOddsEurope">
delete from biz_odds_europe where match_id=#{matchId} and company_id in
<foreach item="item" collection="oeList" separator="," open="(" close=")" index="">
#{item.companyId}
</foreach>
</delete>這里的 collection="#{oeList}"就對應(yīng)Map中的key為oeList的值了。
參考資料
https://www.cnblogs.com/fnlingnzb-learner/p/10566452.html
到此這篇關(guān)于mybatis foreach 批量刪除 傳兩個參數(shù)的文章就介紹到這了,更多相關(guān)mybatis foreach 批量刪除內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
IDEA報java:?java.lang.OutOfMemoryError:?Java?heap?space錯誤
這篇文章主要給大家介紹了關(guān)于IDEA報java:?java.lang.OutOfMemoryError:?Java?heap?space錯誤的解決辦法,文中將解決的辦法介紹的非常詳細,需要的朋友可以參考下2024-01-01
springboot代碼,注解配置獲取yml,properties文件的map即鍵值對
這篇文章主要介紹了springboot代碼,注解配置獲取yml,properties文件的map即鍵值對,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-02-02
高效數(shù)據(jù)傳輸?shù)拿孛芪淦鱌rotobuf的使用教程
Protobuf(Protocol?Buffers)是由?Google?開發(fā)的一種輕量級、高效的數(shù)據(jù)交換格式,它被用于結(jié)構(gòu)化數(shù)據(jù)的序列化、反序列化和傳輸,本文主要介紹了它的具體使用方法,需要的可以參考一下2023-05-05
關(guān)于SpringMVC中控制器如何處理文件上傳的問題
這篇文章主要介紹了關(guān)于SpringMVC中控制器如何處理文件上傳的問題,在 Web 應(yīng)用程序中,文件上傳是一個常見的需求,例如用戶上傳頭像、上傳文檔等,本文將介紹 Spring MVC 中的控制器如何處理文件上傳,并提供示例代碼,需要的朋友可以參考下2023-07-07
Spring?Security放行的接口Knife4j靜態(tài)資源的問題小結(jié)
這篇文章主要介紹了Spring?Security使用Knife4j靜態(tài)資源的問題小結(jié),項目中使用?Spring?Security?做身份認(rèn)證和授權(quán),使用?Knife4j?做接口調(diào)試,需要?Spring?Security?放行的接口記錄在?RequestMatcherConstant?類中,感興趣的朋友跟隨小編一起看看吧2024-02-02

