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