zoukankan      html  css  js  c++  java
  • mybatis 批量更新

    摘抄自:https://blog.csdn.net/LQQianLee/article/details/79771618

        

    二、批量更新——单条件

    1.  
      <update id="update" parameterType="java.util.List">
    2.  
      update nt_menu
    3.  
      <trim prefix="set" suffixOverrides=",">
    4.  
      <trim prefix="breakfast =case" suffix="end,">
    5.  
      <foreach collection="list" item="cus">
    6.  
      <if test="cus.breakfast != null">
    7.  
      when menuId=#{cus.menuId} then #{cus.breakfast}
    8.  
      </if>
    9.  
      </foreach>
    10.  
      </trim>
    11.  
      <trim prefix="lunch =case" suffix="end,">
    12.  
      <foreach collection="list" item="cus">
    13.  
      <if test="cus.lunch != null">
    14.  
      when menuId=#{cus.menuId} then #{cus.lunch}
    15.  
      </if>
    16.  
      </foreach>
    17.  
      </trim>
    18.  
      <trim prefix="dinner =case" suffix="end,">
    19.  
      <foreach collection="list" item="cus">
    20.  
      <if test="cus.dinner != null">
    21.  
      when menuId=#{cus.menuId} then #{cus.dinner}
    22.  
      </if>
    23.  
      </foreach>
    24.  
      </trim>
    25.  
      <trim prefix="modifier =case" suffix="end,">
    26.  
      <foreach collection="list" item="cus">
    27.  
      <if test="cus.modifier != null">
    28.  
      when menuId=#{cus.menuId} then #{cus.modifier}
    29.  
      </if>
    30.  
      </foreach>
    31.  
      </trim>
    32.  
      </trim>
    33.  
      <where>
    34.  
      <foreach collection="list" separator="or" item="cus">
    35.  
      menuId=#{cus.menuId}
    36.  
      </foreach>
    37.  
      </where>
    38.  
      </update>

    批量更新——多条件

  • 相关阅读:
    iOS 面试题汇总
    iOS管理文件和目录
    文件管理
    Cocoapods依赖管理
    IOS开发几何类方法 CGGeometry.h文件
    CGContext
    respondsToSelector的相关使用
    Java数组5作业(2015-8-27)
    Java错误1(2015-8-27)
    Java数组4(2015-8-27)
  • 原文地址:https://www.cnblogs.com/shujiying/p/14341875.html
Copyright © 2011-2022 走看看