集成mybatis批量update问题

<!-- 多条语句批量更新用的是拼接批量执行的方法 -->
<update id="updateDemo">
        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
        update firm_comm
        set ...
        where ...
        </foreach>
    </update>

问题:
项目执行时一直报错,将语句直接在数据库中可执行。排查发现连接数据库时未允许多条语句批量执行
解决:
连接数据库时加上allowMultiQueries=true在SQL语句后加分号;允许多条执行

posted @ 2022-10-24 11:02  _zjk  阅读(33)  评论(0)    收藏  举报