zoukankan      html  css  js  c++  java
  • Mybaties 实现批量修改

    通常我们在做批量更新的时候都会用in 去操作,但in的数据量一上来,就变的缓慢了

    修改方案:

    <update id="updateShufflingSeq" parameterType="java.util.List">
    <foreach collection="list" separator=";" index="index" item="item" open="" close=";">
    update t_shuffling set order_seq=#{item.order_seq} where id = #{item.id}
    </foreach>
    </update>

    关键代码就是标黄部分。但很多时候这个语法是在mysql是默认不支持的,只能修改到最后一条数据

    我们需要在链接数据库的时候添加  allowMultiQueries=true 这个属性。

    最后渲染出来的语句大概是这样的 

    update table set xx=xx where xxx= xxx; 

    update table set xx=xx where xxx= xxx; 

    update table set xx=xx where xxx= xxx; 

    update table set xx=xx where xxx= xxx; 

  • 相关阅读:
    JZOJ 5870 地图
    20190921
    20190919
    SP703 SERVICE
    UVA323 Jury Compromise
    [note]一类位运算求最值问题
    [BZOJ3674]可持久化并查集
    [luogu3359]改造异或树
    [luogu4755]Beautiful Pair
    [BJWC2012]冻结
  • 原文地址:https://www.cnblogs.com/memoa/p/10142295.html
Copyright © 2011-2022 走看看