错误记录—Mybatis中批量修改时出现的报错问题

今天在使用mybatis批量修改时报错,错误为sql语句错误:
开始检查xml中代码:

<update id="updateTypeList" parameterType="list">
        <foreach collection="list" item="type" index="index" separator=";">
            UPDATE t_type
            <set>
                <if test="type.name != null">
                    t_name = #{type.name}
                </if>
            </set>
            where t_id = #{type.id}
        </foreach>
    </update>

感觉并没有错误,把错误语句复制到Navicat上能正常运行,于是网上查找了一下需要在url语句中添加allowMultiQueries=true,添加后成功运行。

Mysql中allowMultiQueries=true作用:
1.可以在sql语句后携带分号,实现多语句执行。
2.可以执行批处理,同时发出多个SQL语句

原文地址:https://www.cnblogs.com/cqy1026/p/13904820.html