mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-13 06:34:50 +00:00
Revert "HHH-16959 Fail to batch delete entities with nested embeddeds"
This reverts commit 8a644d8436a780e84cf05508dec613636e3d1e31.
This commit is contained in:
parent
8a644d8436
commit
1df44f7416
@ -70,7 +70,6 @@ protected Dialect dialect() {
|
||||
|
||||
protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) {
|
||||
if ( !dynamicUpdate
|
||||
&& !entityPersister().optimisticLockStyle().isAllOrDirty()
|
||||
&& session.getTransactionCoordinator() != null
|
||||
&& session.getTransactionCoordinator().isTransactionActive() ) {
|
||||
return this::getBatchKey;
|
||||
|
@ -25,8 +25,6 @@
|
||||
import org.hibernate.persister.entity.AbstractEntityPersister;
|
||||
import org.hibernate.sql.model.MutationOperationGroup;
|
||||
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.RestrictedTableMutationBuilder;
|
||||
import org.hibernate.sql.model.ast.builder.TableDeleteBuilder;
|
||||
@ -436,25 +434,17 @@ private void breakDownJdbcValues(
|
||||
Object loadedValue) {
|
||||
final RestrictedTableMutationBuilder<?, ?> tableMutationBuilder =
|
||||
mutationGroupBuilder.findTableDetailsBuilder( attribute.getContainingTableExpression() );
|
||||
if ( tableMutationBuilder != null ) {
|
||||
final ColumnValueBindingList optimisticLockBindings = tableMutationBuilder.getOptimisticLockBindings();
|
||||
if ( optimisticLockBindings != null ) {
|
||||
attribute.breakDownJdbcValues(
|
||||
loadedValue,
|
||||
(valueIndex, value, jdbcValueMapping) -> {
|
||||
final ColumnValueBinding valueBinding = optimisticLockBindings.createValueBinding(
|
||||
jdbcValueMapping.getSelectableName(),
|
||||
value == null ? null : jdbcValueMapping.getWriteExpression(),
|
||||
jdbcValueMapping.getJdbcMapping()
|
||||
);
|
||||
if ( !tableMutationBuilder.getKeyRestrictionBindings().contains( valueBinding ) ) {
|
||||
optimisticLockBindings.add( valueBinding );
|
||||
}
|
||||
if ( tableMutationBuilder != null && tableMutationBuilder.getOptimisticLockBindings() != null ) {
|
||||
attribute.breakDownJdbcValues(
|
||||
loadedValue,
|
||||
(valueIndex, value, jdbcValueMapping) -> {
|
||||
if ( value != null && !tableMutationBuilder.getKeyRestrictionBindings().contains( value ) ) {
|
||||
tableMutationBuilder.getOptimisticLockBindings().consume( valueIndex, value, jdbcValueMapping );
|
||||
}
|
||||
,
|
||||
session
|
||||
);
|
||||
}
|
||||
}
|
||||
,
|
||||
session
|
||||
);
|
||||
}
|
||||
// else there is no actual delete statement for that table,
|
||||
// generally indicates we have an on-delete=cascade situation
|
||||
|
@ -6,8 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.sql.model.ast;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
|
||||
/**
|
||||
@ -40,21 +38,4 @@ public ColumnWriteFragment getValueExpression() {
|
||||
public String toString() {
|
||||
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 void addRestriction(String columnName, String columnWriteFragment, JdbcMa
|
||||
add( createValueBinding( columnName, columnWriteFragment, jdbcMapping ) );
|
||||
}
|
||||
|
||||
public ColumnValueBinding createValueBinding(
|
||||
protected ColumnValueBinding createValueBinding(
|
||||
String columnName,
|
||||
String customWriteExpression,
|
||||
JdbcMapping jdbcMapping) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user