fix(api): clear EntityManager before deleting books (#1467)

This commit is contained in:
James Ward
2026-05-23 20:58:17 -06:00
committed by GitHub
parent db09c39192
commit f9d9000706
2 changed files with 12 additions and 3 deletions
@@ -462,13 +462,13 @@ public class BookService {
}
}
bookRepository.deleteAllInBatch(books);
// Because this is `InBatch` we need to clear and flush the entity manager to
// prevent unexpected updates of records when the transaction commits.
entityManager.flush();
entityManager.clear();
bookRepository.deleteAllInBatch(books);
auditService.log(AuditAction.BOOK_DELETED, "Deleted " + ids.size() + " book(s)");
BookDeletionResponse response = new BookDeletionResponse(ids, failedFileDeletions);
return failedFileDeletions.isEmpty()