From 4ce518b8069a180b7d2c05ea734816038a304428 Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Fri, 24 Jan 2025 08:16:40 +0100 Subject: [PATCH] [#2079] Don't ignore return value of ReactiveUpdateRowsCoordinatorOneToMany#deleteRows --- ...eactiveUpdateRowsCoordinatorOneToMany.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/mutation/ReactiveUpdateRowsCoordinatorOneToMany.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/mutation/ReactiveUpdateRowsCoordinatorOneToMany.java index 99bec6f5a..8b7478efa 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/mutation/ReactiveUpdateRowsCoordinatorOneToMany.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/mutation/ReactiveUpdateRowsCoordinatorOneToMany.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.concurrent.CompletionStage; +import java.util.function.Function; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; @@ -28,9 +29,9 @@ import static java.lang.invoke.MethodHandles.lookup; import static org.hibernate.reactive.logging.impl.LoggerFactory.make; -import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture; import static org.hibernate.reactive.util.impl.CompletionStages.loop; import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; +import static org.hibernate.reactive.util.impl.CompletionStages.zeroFuture; import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER; import static org.hibernate.sql.model.MutationType.DELETE; import static org.hibernate.sql.model.MutationType.INSERT; @@ -70,15 +71,18 @@ public CompletionStage reactiveUpdateRows(Object key, PersistentCollection } private CompletionStage doReactiveUpdate(Object key, PersistentCollection collection, SharedSessionContractImplementor session) { - if ( rowMutationOperations.hasDeleteRow() ) { - deleteRows( key, collection, session ); - } + final Function> insertRowsFun = v -> { + if ( rowMutationOperations.hasInsertRow() ) { + return insertRows( key, collection, session ); + } - if ( rowMutationOperations.hasInsertRow() ) { - return insertRows( key, collection, session ); + return zeroFuture(); + }; + if ( rowMutationOperations.hasDeleteRow() ) { + return deleteRows( key, collection, session ) + .thenCompose( insertRowsFun ); } - - return completedFuture( 0 ); + return insertRowsFun.apply( null ); } private CompletionStage insertRows(Object key, PersistentCollection collection, SharedSessionContractImplementor session) {