在 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);
简单高效