From 00baf0d8816834da3a66c27d4caa6ecfcce97aaa Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 11 Jun 2026 19:22:12 +0200 Subject: [PATCH] refactor(geschichte): make flush-before-delete explicit on note-less cleanup (#805) Adds flushAutomatically = true to @Modifying on deleteNoteLessByDocumentId so the flush-before-bulk-delete contract is explicit instead of relying on Hibernate AUTO flush-mode behaviour. Addresses @markus review on PR #806. Co-Authored-By: Claude Opus 4.8 --- .../geschichte/journeyitem/JourneyItemRepository.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemRepository.java b/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemRepository.java index 130490f7..7f7d38ab 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemRepository.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/geschichte/journeyitem/JourneyItemRepository.java @@ -51,9 +51,10 @@ public interface JourneyItemRepository extends JpaRepository * Explicit JPQL — same trap as existsByGeschichteIdAndDocumentId: the transient * getDocumentId() getter makes Spring Data unable to resolve a derived query path. * clearAutomatically = true invalidates the L1 cache so AC-2's "note-carrying survives" - * assertion never reads a stale entity. + * assertion never reads a stale entity. flushAutomatically = true makes the + * flush-before-delete contract explicit rather than relying on Hibernate AUTO flush mode. */ - @Modifying(clearAutomatically = true) + @Modifying(clearAutomatically = true, flushAutomatically = true) @Query("DELETE FROM JourneyItem i WHERE i.document.id = :documentId AND (i.note IS NULL OR i.note = '')") int deleteNoteLessByDocumentId(@Param("documentId") UUID documentId);