当前位置: 代码迷 >> 综合 >> 记一次mybatis批量更新的坑&allowMultiQueries=true 属性,允许批量更新
  详细解决方案

记一次mybatis批量更新的坑&allowMultiQueries=true 属性,允许批量更新

热度:66   发布时间:2024-02-06 15:14:05.0

1.下面是我写的代码,看起来没有问题,但就是运行不起来,

<update id="updates" parameterType="java.util.List">

        <foreach collection="list" item="item" separator=";">
update sys_dev
<set>
IsCorrect=1,UserChoice=#{item.userchoice}
</set>
where HistoryId=#{item.historyid}
</foreach>
</update>

2.我们要在数据库连接上设置上&allowMultiQueries=true属性

jdbc:mysql://192.168.2.0:3306/dev?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&allowMultiQueries=true

3.之后在运行就更新成功了

  相关解决方案