I don’t need to say more about the role of MyBatis. Today I will talk about the batch deletion operation in MyBatis. Without further ado, I will give you a code snippet first!
<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>or <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> The attributes of the foreach element are mainly item, index, collection, open, separator, and close.
Item represents the alias when each element in the collection is iterated. (Sign up all elements in the corresponding delList collection, the item in item="item" (the latter one) must be consistent with the item in #{item})
index specifies a name that represents the position to which each iteration is reached during the iteration process.
open means what starts with the statement, and separator means what symbols are used as separators between each iteration.
close indicates what ends.
The above is the Mybatis batch deletion operation method introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!