第五章 mybatis批量更新update

一、所有的指定id的模型类的同一个字段进行批量更新

实际上:

update t set fileld='xx' where id in (id1,id2,...,idn)

代码:

<update id="updateBatch" parameterType="Map">
        update t_name
        set name = #{name,jdbcType=VARCHAR}
        where autoid in 
        (
        <foreach collection="list" item="item" separator=",">
            #{item.id,jdbcType=BIGINT}
        </foreach>
        )
    </update>
void updateBatch(@Param("list") List<User> list, @Param("name") String name);

二、指定id的模型类的不同字段进行批量更新

参考:http://blog.csdn.net/tolcf/article/details/39213217

原文地址:https://www.cnblogs.com/java-zhao/p/5864499.html