采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
老师,请问下,通用mapper怎么设置不更新和不插入空字符串? 这边通过insertSelective和UpdateByPrimaryKeySelectiveMapper发现前端传过来的空字符会更新和插入,应该null和空字符都不插入才对吧
您好,直接判断下就OK了。
if(入参不是null) {
insertSelective / UpdateByPrimaryKey
}
通用mapper不会管你是不是想要插入的是空还是不是空。
可以通过在配置文件开启是否判断为空字符串或null则不执行 mapper: mapper: - tk.mybatis.mapper.common.Mapper notEmpty: true notEmpty insertSelective 和 updateByPrimaryKeySelective 中,是否判断字符串类型 !=''。 配置方式: mapper.not-empty=true
登录后可查看更多问答,登录/注册
面向未来微服务:熟练掌握Spring Cloud Alibaba
882 4
2.3k 1
3.1k 2
2.1k 3
4.3k 13
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号