myBatis 批量xml

批量插入xml

  <insert id="batchSaves" useGeneratedKeys="true"  keyProperty="relId" parameterType="java.util.List" >
    insert into categorys_display_mapping (rel_id, display_category_code, display_category_name,
    category_code, status, create_oper_id,
    create_time, update_oper_id, update_time,
    remark, first_cate_code, first_cate_name,
    second_cate_code, second_cate_name, ext_json
    ) values
    <foreach collection="list" item="item"  separator=",">
      (#{item.relId,jdbcType=BIGINT}, #{item.displayCategoryCode,jdbcType=VARCHAR}, #{item.displayCategoryName,jdbcType=VARCHAR},
      #{item.categoryCode,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.createOperId,jdbcType=VARCHAR},
      #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateOperId,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
      #{item.remark,jdbcType=VARCHAR}, #{item.firstCateCode,jdbcType=VARCHAR}, #{item.firstCateName,jdbcType=VARCHAR},
      #{item.secondCateCode,jdbcType=VARCHAR}, #{item.secondCateName,jdbcType=VARCHAR}, #{item.extJson,jdbcType=LONGVARCHAR}
      )
    </foreach>
  </insert>

批量修改

<update id="batchUpdates" parameterType="list">
    <foreach collection="list" item="item" separator=";">
      UPDATE categorys_display_mapping
      <set>
        <if test="item.displayCategoryCode != null">
          displayCategoryCode = #{item.displayCategoryCode},
        </if>
        <if test="item.displayCategoryName != null">
          displayCategoryName = #{item.displayCategoryName},
        </if>
        <if test="item.categoryCode != null">
          categoryCode = #{item.categoryCode},
        </if>
        <if test="item.status != null">
          status = #{item.status},
        </if>
        <if test="item.createOperId != null">
          createOperId = #{item.createOperId},
        </if>
        <if test="item.createTime != null">
          createTime = #{item.createTime},
        </if>
        <if test="item.updateOperId != null">
          updateOperId = #{item.updateOperId},
        </if>
        <if test="item.updateTime != null">
          updateTime = #{item.updateTime},
        </if>
        <if test="item.remark != null">
          remark = #{item.remark},
        </if>
        <if test="item.firstCateCode != null">
          firstCateCode = #{item.firstCateCode},
        </if>
        <if test="item.firstCateName != null">
          firstCateName = #{item.firstCateName},
        </if>
        <if test="item.secondCateCode != null">
          secondCateCode = #{item.secondCateCode},
        </if>
        <if test="item.secondCateName != null">
          secondCateName = #{item.secondCateName},
        </if>
        <if test="item.extJson != null">
          extJson = #{item.extJson},
        </if>
      </set>
      WHERE rel_id = #{categorys_display_mapping.rel_id}
    </foreach>
  </update>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值