首页 > 其他 > 详细

mybatis批量添加、批量删除

时间:2018-06-23 20:33:43      阅读:238      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!