MyBatis的作用我想不用多說(shuō),今天說(shuō)說(shuō)MyBatis中的批量刪除操作。廢話不多說(shuō),先給大家一段代碼片段!
1
2
3
4
5
6
7
8
9
10
|
<delete id= "deleteByStandardIds" > delete from t_standard_catalog where standard_id in <foreach collection= "array" item= "standardId" open= "(" close= ")" separator= "," > #{standardId,jdbcType=INTEGER} </foreach></delete>或者 <delete id= "deleteByStandardIds" parameterType= "java.util.List" > delete from t_standard_catalog where standard_id in <foreach collection= "list" item= "standardId" open= "(" close= ")" separator= "," > #{standardId,jdbcType=INTEGER} </foreach> </delete> |
foreach元素的屬性主要有 item,index,collection,open,separator,close。
item表示集合中每一個(gè)元素進(jìn)行迭代時(shí)的別名. (直接找到對(duì)應(yīng)的delList集合里面的所有元素,item="item"中的item(后一個(gè))必須與#{item} 中的item一致)
index指 定一個(gè)名字,用于表示在迭代過(guò)程中,每次迭代到的位置.
open表示該語(yǔ)句以什么開(kāi)始,separator表示在每次進(jìn)行迭代之間以什么符號(hào)作為分隔 符.
close表示以什么結(jié)束.
以上所述是小編給大家介紹的Mybatis批量刪除數(shù)據(jù)操作方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持!
原文鏈接:http://www.cnblogs.com/esther-qing/archive/2016/09/23/5898884.html