在 MyBatis-Plus 中,字段更新为 null 的方法
在 MyBatis-Plus 中,BaseMapper#updateById 方法默认情况下不会更新为 null 的字段。要更新为 null,需要进行一些配置,或者自定义update方法。
这里记录一下使用BaseMapper中UpdateWrapper进行null值更新。
UpdateWrapper<ErpProductSupplierDO> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id)
.set("offer_id", null)
.set("spec_id", null)
.set("open_offer_id", null)
.set("sku_id", null);
productSupplierMapper.update(null, updateWrapper);
简单高效
原文地址:https://blog.csdn.net/qq_43048011/article/details/140359167
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!