首页 > 其他 > 详细

mybatis 批量update报语法错误解决方法

时间:2019-07-08 14:46:55      阅读:147      评论:0      收藏:0      [点我收藏+]

1、为什么会报语法错误

  原因:在 *.xml文件内使用了循环,在mybatis中默认是不允许使用批量修改。

<update id="setMaxMin" parameterType="java.util.List">
    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
        update fm_info
        <set>
            max_degree= #{item.maxDegree,jdbcType=decimal},
min_degree= #{item.minDegree,jdbcType=decimal},
degree= #{item.degree,jdbcType=decimal} </set> <where> id = #{item.id,jdbcType=INTEGER} </where> </foreach> </update>

2、解决方法

  在连接mysql的url后面加上 《   allowMultiQueries=true   》

jdbc.url=jdbc:mysql://localhost:3306/flow_meter?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true

 

mybatis 批量update报语法错误解决方法

原文:https://www.cnblogs.com/zhangweibin/p/11150306.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!