前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。?
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 對你注入的字段全部更新,將為空的字段在數據庫中置為NULL
轉自:https://blog.csdn.net/a670941001/article/details/54619432?