丨钢琴丶

MyBatisPlus的UpdateWrapper用法

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);

 

posted on 2020-09-18 10:46  丨钢琴丶  阅读(36557)  评论(0编辑  收藏  举报

导航