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


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM