oracle mybatis批量插入(效率快一些),批量更新

datalist中map的顺序需要与lineColumn对应
<insert id="insertIndi" parameterType="java.util.HashMap" useGeneratedKeys="false">
<![CDATA[
INSERT INTO TABLEA(${lineColumn})
select results.* from(
]]>
<foreach collection="datalist" item="item" index="index" separator="union all" >
(select
<foreach collection="item.values" index="key" item="_value" separator=",">
#{_value}
</foreach>
from dual)
</foreach>
<![CDATA[) results]]>
</insert>

<update id="updataData" parameterType="java.util.HashMap" useGeneratedKeys="false">
<foreach collection="datalist" item="item" index="index" open="begin" close="; end;" separator=";">
update ${tablename} set
<foreach collection="item" index="_key" item="_value" separator=",">
${_key} = #{_value}
</foreach>
where guid = #{item.GUID}
</foreach>
</update>

原文地址:https://www.cnblogs.com/sx2zx/p/10832320.html