From fb4eac458d3dc646ebd177fd7720c7807a6e1237 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Mon, 17 Mar 2025 23:08:43 +0800 Subject: [PATCH] =?UTF-8?q?perf(warehouse):=20=E4=BC=98=E5=8C=96=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=95=86=E5=93=81=E6=9B=B4=E6=96=B0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=9A=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在保存库存商品实体后,添加了 EntityManager 的 flush 操作 - 这样可以确保在更新数据库之前,所有待处理的变更都被提交- 从而避免不必要的数据库查询,提高系统性能 --- .../coal/warehouseGoods/service/WarehouseGoodsService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java b/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java index 278b73bc..79e27fed 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java +++ b/src/main/java/cn/lihongjie/coal/warehouseGoods/service/WarehouseGoodsService.java @@ -60,6 +60,7 @@ public class WarehouseGoodsService WarehouseGoodsEntity entity = mapper.toEntity(request); this.repository.save(entity); + em.flush(); em.refresh(entity); return getById(entity.getId()); }