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);
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Blazor Hybrid适配到HarmonyOS系统
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库