HHH-16112 No expectation for one-shot collection delete using update

This commit is contained in:
Marco Belladelli 2023-02-02 14:08:04 +01:00 committed by Christian Beikov
parent 6feaf2a9e9
commit 8f4cbd335f
2 changed files with 19 additions and 3 deletions

View File

@ -25,6 +25,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.internal.util.NullnessHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jdbc.Expectations;
import org.hibernate.mapping.Collection;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
@ -390,7 +391,8 @@ public class OneToManyPersister extends AbstractCollectionPersister {
keyRestrictionBindings,
null,
parameterBinders,
sqlWhereString
sqlWhereString,
Expectations.NONE
);
}

View File

@ -8,6 +8,7 @@ package org.hibernate.sql.model.internal;
import java.util.List;
import org.hibernate.jdbc.Expectation;
import org.hibernate.sql.ast.SqlAstWalker;
import org.hibernate.sql.model.MutationTarget;
import org.hibernate.sql.model.ast.AbstractTableUpdate;
@ -22,6 +23,8 @@ import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
public class TableUpdateStandard extends AbstractTableUpdate<JdbcMutationOperation> {
private final String whereFragment;
private final Expectation expectation;
public TableUpdateStandard(
MutatingTableReference mutatingTable,
MutationTarget<?> mutationTarget,
@ -31,6 +34,7 @@ public class TableUpdateStandard extends AbstractTableUpdate<JdbcMutationOperati
List<ColumnValueBinding> optLockRestrictionBindings) {
super( mutatingTable, mutationTarget, sqlComment, valueBindings, keyRestrictionBindings, optLockRestrictionBindings );
this.whereFragment = null;
this.expectation = null;
}
public TableUpdateStandard(
@ -41,7 +45,7 @@ public class TableUpdateStandard extends AbstractTableUpdate<JdbcMutationOperati
List<ColumnValueBinding> keyRestrictionBindings,
List<ColumnValueBinding> optLockRestrictionBindings,
List<ColumnValueParameter> parameters) {
this( tableReference, mutationTarget, sqlComment, valueBindings, keyRestrictionBindings, optLockRestrictionBindings, parameters, null );
this( tableReference, mutationTarget, sqlComment, valueBindings, keyRestrictionBindings, optLockRestrictionBindings, parameters, null, null );
}
public TableUpdateStandard(
@ -52,9 +56,11 @@ public class TableUpdateStandard extends AbstractTableUpdate<JdbcMutationOperati
List<ColumnValueBinding> keyRestrictionBindings,
List<ColumnValueBinding> optLockRestrictionBindings,
List<ColumnValueParameter> parameters,
String whereFragment) {
String whereFragment,
Expectation expectation) {
super( tableReference, mutationTarget, sqlComment, valueBindings, keyRestrictionBindings, optLockRestrictionBindings, parameters );
this.whereFragment = whereFragment;
this.expectation = expectation;
}
@Override
@ -75,4 +81,12 @@ public class TableUpdateStandard extends AbstractTableUpdate<JdbcMutationOperati
public void accept(SqlAstWalker walker) {
walker.visitStandardTableUpdate( this );
}
@Override
public Expectation getExpectation() {
if ( expectation != null ) {
return expectation;
}
return super.getExpectation();
}
}