mybatis批量添加批量删除
Posted 风云灬信任
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis批量添加批量删除相关的知识,希望对你有一定的参考价值。
<!-- 批量添加 -->
<insert id="insertNameListSynHisBatch" parameterType="java.util.List" useGeneratedKeys="false">
insert into tb_namelist_syn_his (SERIAL, RECORDNUMBER, HASHTBNAME,
CTLTYPE, SOURCE, CREATETIME,
CKEY, CVALUE)
<foreach collection="list" item="his" index="index" separator=" union all ">
(
SELECT #{his.serial,jdbcType=VARCHAR},
#{his.recordnumber,jdbcType=VARCHAR},
#{his.hashtbname,jdbcType=VARCHAR},
#{his.ctltype,jdbcType=VARCHAR},
#{his.source,jdbcType=INTEGER},
#{his.createtime,jdbcType=DATE},
#{his.ckey,jdbcType=VARCHAR},
#{his.cvalue,jdbcType=VARCHAR}
FROM DUAL
)
</foreach>
</insert>
<!-- 批量删除 -->
<delete id="deleteNameListSynHisBatch" parameterType="java.util.List">
delete from tb_namelist_syn A
where exists
(
select 1 from(
<foreach collection="list" item="item" index="index" separator="union all">
select B.* from tb_namelist_syn B where 1=1 and B.serial=#{item.serial,jdbcType=VARCHAR}
</foreach>
)S where A.serial=S.serial
)
</delete>
如果不用@param系统默认list
以上是关于mybatis批量添加批量删除的主要内容,如果未能解决你的问题,请参考以下文章