mybatis_plus

MybatisPlus的update默认机制是更新字段时判断是否为null,做值为null,则不更新该字段
当我们需要将部分字段更新为null时,可利用UpdateWrapper解决该问题
UpdateWrapper用法
1 WarehouseItem warehouseItem = warehouseItemService.getById(2117733125);
2 UpdateWrapper<WarehouseItem> updateWrapper = new UpdateWrapper<>();
3 //可将指定字段更新为null
4 updateWrapper.set("ownerId", null); 
5 updateWrapper.set("product_id",123456);
6 warehouseItemService.update(warehouseItem, updateWrapper);

原文地址:https://www.cnblogs.com/zhuxiang1029/p/15174913.html