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

    1.需求

      后台管理页面,查询频道列表,需要批量修改频道的状态,批量上线和下线

    2.MyBatis配置

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

    jdbc_url=jdbc:mysql://localhost:3306/go?useUnicode=true&characterEncoding=UTF-8&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>

    3. 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的没有试过

     参考http://my.oschina.net/jsonavaj/blog/265112

  • 相关阅读:
    巩固复习(对以前的随笔总结)_01
    Django 项目分析后得到的某些结论
    django 命令行命令
    实现搜索视频到播放(非原创)
    python 打包
    随笔汇总,温故知新
    找伙伴
    sam-Toy Cars
    反质数
    Blue Mary的战役地图
  • 原文地址:https://www.cnblogs.com/liuchao102/p/4588982.html
Copyright © 2011-2022 走看看