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

 

上面的是逆转工程生成的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>
<update id="updateByPrimaryKey" parameterType="com.taotao.pojo.TbItem">
update tb_item
set title = #{title,jdbcType=VARCHAR},
where id = #{id,jdbcType=BIGINT}
</update>

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

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

相关文章:

  • 2022-12-23
  • 2021-08-29
  • 2021-11-04
  • 2021-07-14
  • 2022-01-12
  • 2021-10-23
  • 2021-09-21
猜你喜欢
  • 2021-10-29
  • 2021-09-05
  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案