Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spring-data-jpa @Modifying(flushAutomatically = true) #42376

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}