Skip to content

Commit 4ce518b

Browse files
committed
[hibernate#2079] Don't ignore return value of ReactiveUpdateRowsCoordinatorOneToMany#deleteRows
1 parent 89f7cf2 commit 4ce518b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/mutation/ReactiveUpdateRowsCoordinatorOneToMany.java

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.util.Iterator;
99
import java.util.concurrent.CompletionStage;
10+
import java.util.function.Function;
1011

1112
import org.hibernate.collection.spi.PersistentCollection;
1213
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
@@ -28,9 +29,9 @@
2829

2930
import static java.lang.invoke.MethodHandles.lookup;
3031
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
31-
import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture;
3232
import static org.hibernate.reactive.util.impl.CompletionStages.loop;
3333
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;
34+
import static org.hibernate.reactive.util.impl.CompletionStages.zeroFuture;
3435
import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER;
3536
import static org.hibernate.sql.model.MutationType.DELETE;
3637
import static org.hibernate.sql.model.MutationType.INSERT;
@@ -70,15 +71,18 @@ public CompletionStage<Void> reactiveUpdateRows(Object key, PersistentCollection
7071
}
7172

7273
private CompletionStage<Integer> doReactiveUpdate(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {
73-
if ( rowMutationOperations.hasDeleteRow() ) {
74-
deleteRows( key, collection, session );
75-
}
74+
final Function<Void, CompletionStage<Integer>> insertRowsFun = v -> {
75+
if ( rowMutationOperations.hasInsertRow() ) {
76+
return insertRows( key, collection, session );
77+
}
7678

77-
if ( rowMutationOperations.hasInsertRow() ) {
78-
return insertRows( key, collection, session );
79+
return zeroFuture();
80+
};
81+
if ( rowMutationOperations.hasDeleteRow() ) {
82+
return deleteRows( key, collection, session )
83+
.thenCompose( insertRowsFun );
7984
}
80-
81-
return completedFuture( 0 );
85+
return insertRowsFun.apply( null );
8286
}
8387

8488
private CompletionStage<Integer> insertRows(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {

0 commit comments

Comments
 (0)