From 17ba20fbe982f52d710c27a6e866ebf3f5e0c072 Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <> Date: Fri, 23 May 2025 11:23:26 -0600 Subject: [PATCH] Ensure updated and deleted books reflect correctly in library view --- .../booklore/service/LibraryProcessingService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java index cef7b7f99..660e668e0 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/LibraryProcessingService.java @@ -111,6 +111,8 @@ public class LibraryProcessingService { @Transactional protected void deleteRemovedBooks(List removedBookEntities) { if (!removedBookEntities.isEmpty()) { + entityManager.flush(); + entityManager.clear(); Set bookIds = removedBookEntities.stream().map(BookEntity::getId).collect(Collectors.toSet()); bookRepository.deleteByIdIn(bookIds); notificationService.sendMessage(Topic.BOOKS_REMOVE, bookIds);