Skip to content

Commit

Permalink
[#2079] Don't ignore return value of ReactiveUpdateRowsCoordinatorOne…
Browse files Browse the repository at this point in the history
…ToMany#deleteRows
  • Loading branch information
DavideD committed Jan 24, 2025
1 parent 89f7cf2 commit 4ce518b
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -70,15 +71,18 @@ public CompletionStage<Void> reactiveUpdateRows(Object key, PersistentCollection
}

private CompletionStage<Integer> doReactiveUpdate(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {
if ( rowMutationOperations.hasDeleteRow() ) {
deleteRows( key, collection, session );
}
final Function<Void, CompletionStage<Integer>> 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<Integer> insertRows(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {
Expand Down

0 comments on commit 4ce518b

Please sign in to comment.