批量修改主要有两种方式
第一种,可以通过for循环一条一条修改数据,这样会影响效率,因此我不推荐,所以在这里我也不多说。
第二种,通过修改mybatis中mapper.xml文件,如下:
<update id="updateRoleMenus" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update TB_ROLE_MENU
<set>
FID=#{item.fid}
</set>
where ROLEID = #{item.roleid}
</foreach>
</update>
本文介绍了一种在MyBatis中批量修改数据的高效方法,通过更新mapper.xml文件中的foreach元素实现,适用于需要对大量数据进行修改的场景。
5519





