Skip to content

Commit c247d46

Browse files
committed
Use loop for creating data with Hibernate Reactive
Currently, is not safe to use the Hibernate Reactive session with `Uni.combine().all()`. Even if it still work for a simple scenario like the one in the benchmark. This commit change it to for loop so that the uni are executed sequentially. Using `.usingConcurrencyOf(1)` would have also worked.
1 parent dca68eb commit c247d46

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • frameworks/Java/quarkus/resteasy-reactive-hibernate-reactive/src/main/java/io/quarkus/benchmark/repository

frameworks/Java/quarkus/resteasy-reactive-hibernate-reactive/src/main/java/io/quarkus/benchmark/repository/WorldRepository.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ public Uni<Void> createData() {
2424
return inSession(s -> {
2525
final LocalRandom random = Randomizer.current();
2626
int MAX = 10000;
27-
Uni<Void>[] unis = new Uni[MAX];
27+
Uni<Void> loop = Uni.createFrom().voidItem();
2828
for (int i = 0; i < MAX; i++) {
2929
final World world = new World();
3030
world.setId(i + 1);
3131
world.setRandomNumber(random.getNextRandom());
32-
unis[i] = s.persist(world).map(v -> null);
32+
loop = loop.call(() -> s.persist(world));
3333
}
34-
return Uni.combine().all().unis(unis).with(l -> null)
35-
.flatMap(v -> s.flush())
36-
.map(v -> null);
34+
return loop.call(s::flush);
3735
});
3836
}
3937

0 commit comments

Comments
 (0)