Mybatis批量更新失败的问题

一个例子,根据ID批量更新一个字段,list接收一个数组参数,代码是没一点毛病的 

<update id="saveRoomId">
    <foreach collection="list" item="item" separator=";" open="" close="">
    update t_prescription_item
    <set>
    room_id = #{item.roomId}
    </set>
    where id = #{item.id}
    </foreach>
  </update>

但是接口一直没起作用

原因及解决方法:SQL批处理需要在你的数据库连接配置属性后面加上allowMultiQueries=true

 jdbc.url=jdbc:mysql://192.168.0.110:3306/db_recover?characterEncoding=UTF-8&allowMultiQueries=true

然后程序可以正常执行

猜你喜欢

转载自blog.csdn.net/weixin_42559574/article/details/109028507