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

    学习资源:https://blog.csdn.net/xyjawq1/article/details/74129316

    <!-- 批量更新模板 -->
    <update id="updateBatch" parameterType="java.util.List">
    update bc_product_combo
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="user_id =case" suffix="end,">
        <foreach collection="list" item="item" index="index">
          <if test="item.userId != null" >
            when id=#{item.id} then #{item.userId,jdbcType=CHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="user_name =case" suffix="end,">
        <foreach collection="list" item="item" index="index">
          <if test="item.userName != null" >
            when id=#{item.id} then #{item.userName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>

    </trim>
    <where>
      id in
      <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
        #{item.id,jdbcType=CHAR}
      </foreach>
    </where>
    </update>

  • 相关阅读:
    WinCE 与通讯模块
    6174问题
    阶乘因式分解(一)
    三个数从小到大排序
    公约数和公倍数
    水仙花数
    韩信点兵
    5个数求最值
    求转置矩阵问题
    孪生素数问题
  • 原文地址:https://www.cnblogs.com/Rage-Leila/p/8888299.html
Copyright © 2011-2022 走看看