1.批量更新
<update id="update" parameterType="List">
<foreach collection="codes" item="item" index="index" open="begin" separator=";" close=";end;">
UPDATE test_table1 a
<set>
code=#{item.code}
</set>
where
a.id=#{item.id}
</foreach>
</update>
2.批量插入
a> 主键不使用序列产生
<insert id="addData" parameterType="java.util.List">
insert into data_table (id,name)
<foreach collection="list" item="data" separator="union all">
select
#{data.id},#{data.name}
from dual
</foreach>
</insert>