java代码 Dao层
int updateBatch(@Param("userList") List<User> userList);
sql配置文件
<update id="updateBatch" parameterType="java.util.List" >
<foreach collection="userList" item="user" separator=",">
UPDATE user
<set>
<if test="user.balance != null">
balance = #{user.balance},
</if>
<if test="user.totalMoney != null">
total_money = #{user.totalMoney},
</if>
<if test="user.previousOrder != null">
previous_order = #{user.previousOrder},
</if>
<if test="user.updateTime != null">
update_time = #{user.updateTime}
</if>
where user_id = #{user.userId}
</set>
</foreach>
</update>