Mybatis中updateByPrimaryKeySelective和updateByPrimaryKey区别
2024-10-21 09:29:47
- 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对你注入的字段全部更新
最新文章
- CPPFormatLibary提升效率的优化原理
- TCP和UDP之间的区别和联系
- Hibernate前置和后置方法
- iOS 关于僵尸对象和僵尸指针的那些事儿
- struts2验证框架
- flexbox in IE (10+ and 9 and 8)
- 【转载】Redis多实例及分区
- HTML第六天学习笔记
- SimpleDateFormat的线程安全问题
- [转] HTML中调用JavaScript的几种情况和规范写法
- Y5V贴片电容(MLCC)容量范围速查表
- sql语句判断两个时间段是否有交集
- a java runtime environment(JRE) or java development kit(JDK) must be....
- 老李谈HTTP1.1的长连接 1
- ●codeforces 553E Kyoya and Train
- Python强大的可变参数传递机制
- Python档案袋( 面向对象 )
- 25. Reverse Nodes in k-Group (JAVA)
- Java中常用的加密算法小结
- 设计模式学习心得<;抽象工厂模式 Abstract Factory>;
热门文章
- thinkphp中怎么判断是手机端访问还是pc端访问?
- <;Android 基础(九)>; Ndk配置与Demo
- 一步步理解typedef
- Windows server 2008 sp2 X64安装sharepoint2007出现兼容性问题无法安装 解决办法
- Tomcat 中部署 web 应用 ---- Dubbo 服务消费者 Web 应用 war 包的部署
- 通过CSS3实现:鼠标悬停图片360度旋转效果
- May 7th 2017 Week 19th Sunday
- SQL的注入式攻击方式和避免方法
- InnoDB多版本(MVCC)实现简要分析
- 是否应该提供一个dao.insertIgnoreNull ? (像updateIgnoreNull一样)