• mybatis 批量更新


    在实际的开发中, 存在一次性插入很多数据,和更新很多数据的情况;

    mysql+Mybatis

    一.Mybatis批量更新

     1 <update id="batchUpdateByIds" parameterType="list">
     2         update crm_member
     3         <trim prefix="set" suffixOverrides=",">
     4             <trim prefix="type =case" suffix="end,">
     5                 <foreach collection="list" item="item" index="index">
     6                     <if test="item.type !=null">
     7                         when id=#{item.id} then #{item.type}
     8                     </if>
     9                 </foreach>
    10             </trim>
    11             <trim prefix="update_by =case" suffix="end,">
    12                 <foreach collection="list" item="item" index="index">
    13                     <if test="item.updateBy !=null and item.updateBy != ''">
    14                         when id=#{item.id} then #{item.updateBy}
    15                     </if>
    16                 </foreach>
    17             </trim>
    18             <trim prefix="update_time =case" suffix="end,">
    19                 <foreach collection="list" item="item" index="index">
    20                     <if test="item.updateTime !=null">
    21                         when id=#{item.id} then #{item.updateTime}
    22                     </if>
    23                 </foreach>
    24             </trim>
    25             <trim prefix="follow_status =case" suffix="end,">
    26                 <foreach collection="list" item="item" index="index">
    27                     <if test="item.followStatus !=null">
    28                         when id=#{item.id} then #{item.followStatus}
    29                     </if>
    30                 </foreach>
    31             </trim>
    32         </trim>
    33         where id in
    34         <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    35             #{item.id}
    36         </foreach>
    37     </update>
  • 相关阅读:
    jenkins
    Nexus5安装PostmarketOS(Alpine Linux)并装上Docker
    Abp Abp.AspNetZeroCore 2.0.0 2.1.1 Path
    音速启动 Vstart 5.7 win10手动移除后台设置主页
    Win10 20h2 19041 任务管理器 性能 蓝屏
    PostMan 在请求中自动添加Header
    LINQPad_6.9.15_Premium
    Byd 字段清单 通过JS端点导入
    SAP B1 修改数据库中b1版本号
    event是啥
  • 原文地址:https://www.cnblogs.com/djq-jone/p/10830947.html
Copyright © 2020-2023  润新知