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 5b7ef46 commit 296b43e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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,8 +70,9 @@ public void testNoAutoFlush() {

final User verifyUser = getUser("JOHN");
// processLoginEvents did not see the new login event
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").isFalse();
}

Expand All @@ -83,8 +85,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 296b43e

Please sign in to comment.