zoukankan      html  css  js  c++  java
  • MyBatis批量修改操作

    首先 这编博客经本人试用过,与理想效果一致

    .MyBatis配置

    这是mysql的配置,注意需要加上&allowMultiQueries=true配置

    jdbc_url=jdbc:mysql://localhost:3306/go?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true

    '&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true' 是重点!之前就是因为这个一直没有成功。。。。

    <update id="batchUpdate"  parameterType="java.util.List">
             <foreach collection="list" item="item" index="index" open="" close="" separator=";">
                   update channels
                   <set>
                     state=${item.state}
                   </set>
                   where id = ${item.id}
            </foreach>
     </update>
    
    
    

    oracle和mysql的配置不一样

    <update id="batchUpdate"  parameterType="java.util.List">
             <foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
                   update channels
                   <set>
                     state=${item.state}
                   </set>
                   where id = ${item.id}
            </foreach>
     </update>
    
    

    Mysql的配置在实际运用中成功了,Oracle的没有试过

    详情 参考 至 https://my.oschina.net/jsonavaj/blog/265112

  • 相关阅读:
    15-数组concat()方法和push比较
    06-使用云储存上传工具
    05-云函数/云数据库的增删改查
    错题1
    c++链表
    8817
    8816
    1177
    1355
    c++期末考
  • 原文地址:https://www.cnblogs.com/userzf/p/10737140.html
Copyright © 2011-2022 走看看