Skip to content

Commit a34e10f

Browse files
authored
Merge pull request #42376 from famod/fix-spring-flushAutomatically
Fix spring-data-jpa `@Modifying(flushAutomatically = true)`
2 parents 5b7ef46 + 296b43e commit a34e10f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

extensions/spring-data-jpa/deployment/src/test/java/io/quarkus/spring/data/deployment/ModifyingQueryWithFlushAndClearTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class ModifyingQueryWithFlushAndClearTest {
3333
public void setUp() {
3434
final User user = getUser("JOHN");
3535
user.setLoginCounter(0);
36+
user.getLoginEvents().clear();
3637
repo.save(user);
3738
}
3839

@@ -69,8 +70,9 @@ public void testNoAutoFlush() {
6970

7071
final User verifyUser = getUser("JOHN");
7172
// processLoginEvents did not see the new login event
73+
assertThat(verifyUser.getLoginEvents()).hasSize(1);
7274
final boolean allProcessed = verifyUser.getLoginEvents().stream()
73-
.allMatch(loginEvent -> loginEvent.isProcessed());
75+
.allMatch(LoginEvent::isProcessed);
7476
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isFalse();
7577
}
7678

@@ -83,8 +85,9 @@ public void testAutoFlush() {
8385
repo.processLoginEventsPlainAutoClearAndFlush();
8486

8587
final User verifyUser = getUser("JOHN");
88+
assertThat(verifyUser.getLoginEvents()).hasSize(1);
8689
final boolean allProcessed = verifyUser.getLoginEvents().stream()
87-
.allMatch(loginEvent -> loginEvent.isProcessed());
90+
.allMatch(LoginEvent::isProcessed);
8891
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isTrue();
8992
}
9093

extensions/spring-data-jpa/runtime/src/main/java/io/quarkus/spring/data/runtime/RepositorySupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ public static void clear(Class<?> clazz) {
7878
}
7979

8080
public static void flush(Class<?> clazz) {
81-
Panache.getSession(clazz).clear();
81+
Panache.getSession(clazz).flush();
8282
}
8383
}

0 commit comments

Comments
 (0)