Skip to content

Commit

Permalink
Fix spring-data-jpa @Modifying(flushAutomatically = true)
Browse files Browse the repository at this point in the history
  • Loading branch information
famod committed Aug 7, 2024
1 parent ff6b789 commit c23eb63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ModifyingQueryWithFlushAndClearTest {
public void setUp() {
final User user = getUser("JOHN");
user.setLoginCounter(0);
user.getLoginEvents().clear();
repo.save(user);
}

Expand Down Expand Up @@ -69,9 +70,7 @@ public void testNoAutoFlush() {

final User verifyUser = getUser("JOHN");
// processLoginEvents did not see the new login event
final boolean allProcessed = verifyUser.getLoginEvents().stream()
.allMatch(loginEvent -> loginEvent.isProcessed());
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isFalse();
assertThat(verifyUser.getLoginEvents()).hasSize(0);
}

@Test
Expand All @@ -83,8 +82,9 @@ public void testAutoFlush() {
repo.processLoginEventsPlainAutoClearAndFlush();

final User verifyUser = getUser("JOHN");
assertThat(verifyUser.getLoginEvents()).hasSize(1);
final boolean allProcessed = verifyUser.getLoginEvents().stream()
.allMatch(loginEvent -> loginEvent.isProcessed());
.allMatch(LoginEvent::isProcessed);
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isTrue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public static void clear(Class<?> clazz) {
}

public static void flush(Class<?> clazz) {
Panache.getSession(clazz).clear();
Panache.getSession(clazz).flush();
}
}

0 comments on commit c23eb63

Please sign in to comment.