zoukankan      html  css  js  c++  java
  • Mybatis中updateByPrimaryKeySelective和updateByPrimaryKey区别

    摘自: https://blog.csdn.net/a670941001/article/details/54619432

    • int updateByPrimaryKeySelective(TbItem record);
    • int updateByPrimaryKey(TbItem record);

    updateByPrimaryKeySelective会对字段进行判断再更新(如果为Null就忽略更新),如果你只想更新某一字段,可以用这个方法。

    updateByPrimaryKeySelective是逆转工程生成的Mapper接口

    对应的xml为

    <update id="updateByPrimaryKeySelective" parameterType="com.taotao.pojo.TbItem">
    update tb_item
    <set>
    <if test="title != null">
    title = #{title,jdbcType=VARCHAR},
    </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
    </update>
    
    
    

     

    updateByPrimaryKey对你注入的字段全部更新 

    <update id="updateByPrimaryKey" parameterType="com.taotao.pojo.TbItem">
    update tb_item
    set title = #{title,jdbcType=VARCHAR},
    where id = #{id,jdbcType=BIGINT}
    </update>
    

      

  • 相关阅读:
    [洛谷P5408]第一类斯特林数·行
    11 React 组件生命周期
    10 React 组件 API
    9 React 列表 & Keys
    8 React 条件渲染
    7 React 事件处理
    6 React Props
    5 React State(状态)
    4 React 组件
    3 JSX语法
  • 原文地址:https://www.cnblogs.com/xinruyi/p/11146697.html
Copyright © 2011-2022 走看看