Revert "HHH-16959 Fail to batch delete entities with nested embeddeds"
This reverts commit 533c1cd22b
.
This commit is contained in:
parent
5ca06af029
commit
9bb1327581
|
@ -65,7 +65,6 @@ public abstract class AbstractMutationCoordinator {
|
||||||
|
|
||||||
protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) {
|
protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) {
|
||||||
if ( !dynamicUpdate
|
if ( !dynamicUpdate
|
||||||
&& !entityPersister().optimisticLockStyle().isAllOrDirty()
|
|
||||||
&& session.getTransactionCoordinator() != null
|
&& session.getTransactionCoordinator() != null
|
||||||
&& session.getTransactionCoordinator().isTransactionActive() ) {
|
&& session.getTransactionCoordinator().isTransactionActive() ) {
|
||||||
return this::getBatchKey;
|
return this::getBatchKey;
|
||||||
|
|
|
@ -26,8 +26,6 @@ import org.hibernate.persister.entity.AbstractEntityPersister;
|
||||||
import org.hibernate.sql.model.MutationOperation;
|
import org.hibernate.sql.model.MutationOperation;
|
||||||
import org.hibernate.sql.model.MutationOperationGroup;
|
import org.hibernate.sql.model.MutationOperationGroup;
|
||||||
import org.hibernate.sql.model.MutationType;
|
import org.hibernate.sql.model.MutationType;
|
||||||
import org.hibernate.sql.model.ast.ColumnValueBinding;
|
|
||||||
import org.hibernate.sql.model.ast.ColumnValueBindingList;
|
|
||||||
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
|
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
|
||||||
import org.hibernate.sql.model.ast.builder.RestrictedTableMutationBuilder;
|
import org.hibernate.sql.model.ast.builder.RestrictedTableMutationBuilder;
|
||||||
import org.hibernate.sql.model.ast.builder.TableDeleteBuilder;
|
import org.hibernate.sql.model.ast.builder.TableDeleteBuilder;
|
||||||
|
@ -441,26 +439,18 @@ public class DeleteCoordinator extends AbstractMutationCoordinator {
|
||||||
Object loadedValue) {
|
Object loadedValue) {
|
||||||
final RestrictedTableMutationBuilder<?, ?> tableMutationBuilder =
|
final RestrictedTableMutationBuilder<?, ?> tableMutationBuilder =
|
||||||
mutationGroupBuilder.findTableDetailsBuilder( attribute.getContainingTableExpression() );
|
mutationGroupBuilder.findTableDetailsBuilder( attribute.getContainingTableExpression() );
|
||||||
if ( tableMutationBuilder != null ) {
|
if ( tableMutationBuilder != null && tableMutationBuilder.getOptimisticLockBindings() != null ) {
|
||||||
final ColumnValueBindingList optimisticLockBindings = tableMutationBuilder.getOptimisticLockBindings();
|
|
||||||
if ( optimisticLockBindings != null ) {
|
|
||||||
attribute.breakDownJdbcValues(
|
attribute.breakDownJdbcValues(
|
||||||
loadedValue,
|
loadedValue,
|
||||||
(valueIndex, value, jdbcValueMapping) -> {
|
(valueIndex, value, jdbcValueMapping) -> {
|
||||||
final ColumnValueBinding valueBinding = optimisticLockBindings.createValueBinding(
|
if ( value != null && !tableMutationBuilder.getKeyRestrictionBindings().contains( value ) ) {
|
||||||
jdbcValueMapping.getSelectableName(),
|
tableMutationBuilder.getOptimisticLockBindings().consume( valueIndex, value, jdbcValueMapping );
|
||||||
value == null ? null : jdbcValueMapping.getWriteExpression(),
|
|
||||||
jdbcValueMapping.getJdbcMapping()
|
|
||||||
);
|
|
||||||
if ( !tableMutationBuilder.getKeyRestrictionBindings().contains( valueBinding ) ) {
|
|
||||||
optimisticLockBindings.add( valueBinding );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// else there is no actual delete statement for that table,
|
// else there is no actual delete statement for that table,
|
||||||
// generally indicates we have an on-delete=cascade situation
|
// generally indicates we have an on-delete=cascade situation
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.sql.model.ast;
|
package org.hibernate.sql.model.ast;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,21 +38,4 @@ public class ColumnValueBinding {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ColumnValueBinding(" + valueExpression + ")";
|
return "ColumnValueBinding(" + valueExpression + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if ( this == o ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ( o == null || getClass() != o.getClass() ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ColumnValueBinding that = (ColumnValueBinding) o;
|
|
||||||
return Objects.equals( columnReference, that.columnReference );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash( columnReference );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ColumnValueBindingList extends ArrayList<ColumnValueBinding> implem
|
||||||
add( createValueBinding( columnName, columnWriteFragment, jdbcMapping ) );
|
add( createValueBinding( columnName, columnWriteFragment, jdbcMapping ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColumnValueBinding createValueBinding(
|
protected ColumnValueBinding createValueBinding(
|
||||||
String columnName,
|
String columnName,
|
||||||
String customWriteExpression,
|
String customWriteExpression,
|
||||||
JdbcMapping jdbcMapping) {
|
JdbcMapping jdbcMapping) {
|
||||||
|
|
Loading…
Reference in New Issue