zoukankan      html  css  js  c++  java
  • mabtis批量修改

    参考:http://blog.csdn.net/tolcf/article/details/39213217#

    批量修改的二种方式

    第一种方式

     
    <update id="updateBatch" parameterType="Map">    
            update aa   set     
                a=#{fptm},    
                b=#{csoftrain}    
            where c in     
            <foreach collection="cs" index="index" item="item" pen="("separator=","close=")">    
                #{item}    
            </foreach>  
    </update>  
    

      

    但是这种方式修改的字段值都是一样的。
     

    第二种方式

    批量修改 需要多条sql语句同时执行,通过separator=";" 分号分割  则需要修改数据库连接配置: 

    添加allowMultiQueries 关键字给定初始值 true     (及在数据库连接配置后 加上 &allowMultiQueries=true)

    比如:jdbc:MySQL://ip:3306/test?useUnicode=true&amp;characterEncoding=UTF-8&allowMultiQueries=true

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

      

  • 相关阅读:
    数据结构与算法(0)--必知必会
    数据结构概览
    Python 数据分析学习路线
    数据分析交互工具--使用jupyter
    Vue项目搭建
    luffy_08
    luffy_07
    luffy_06
    luffy_05
    luffy_04
  • 原文地址:https://www.cnblogs.com/dreammyone/p/6994787.html
Copyright © 2011-2022 走看看