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 @   远涉它方  阅读(5097)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
点击右上角即可分享
微信分享提示