1.批量修改
void updateMachiningPriceBatch(@Param(value = "users") List<User> users);
<update id="updateBatch" parameterType="java.util.List">
<foreach collection="users" item="user" index="index" open="" close="" separator=";">
update user
set
age= #{user.age}
where
name = #{user.name}
</foreach>
</update>
Preparing:
update user SET age = ? where name = ?;
update user SET age = ? where name = ?
注意:foreach 中的separator必须为";",这样多条sql语句才能批量执行