码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis批量添加、批量删除

时间:2018-06-23 21:00:41      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:批量添加   item   val   list   ash   ati   syn   each   als   

<!-- 批量添加 -->
<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批量添加、批量删除

标签:批量添加   item   val   list   ash   ati   syn   each   als   

原文地址:https://www.cnblogs.com/stormy/p/9218467.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!