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);