Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ignore return value of deleteRows #2085

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading