1,//批量插入数据,传入参数list
<insert id="insertInfo">
insert into tableName
(
id....
)
values
<foreach collection="list" item="entity" index="index" separator=",">
(
#{entity.id,jdbcType=VARCHAR}....
)
</foreach>
</insert>
2,//批量修改数据
update table set column='...' where id in (1,2,3) //这样的sql就可以了。
//Mybatis中这样写就行 (针对修改相同的数据)
<update id="update" parameterType="java.util.Map" >
UPDATE tableNamw SET name = #{name}
WHERE id IN
<foreach collection="list" item="entity" index="index" open="(" separator="," close=")">
#{entity.xxx}
</foreach>
</update>
//(针对修改不同的数据) <update id="batchUpdate" parameterType="java.util.List">
<foreach close="" collection="list" index="index" item="item" open="" separator=";">
update tableName
set name=#{item.name,jdbcType=VARCHAR},
age=#{item.age,jdbcType=INTEGER}
where id=#{item.id,jdbcType=INTEGER}
</foreach>
</update>