HHH-17279 Get rid of MultiTableSqmMutationConverter#visitInsertionTargetPaths
This commit is contained in:
parent
e6f26e0754
commit
1cbbf9f50a
|
@ -165,19 +165,6 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter<Sta
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Specialized hook to visit the target paths defined by the insert SQM.
|
|
||||||
*/
|
|
||||||
public AdditionalInsertValues visitInsertionTargetPaths(
|
|
||||||
BiConsumer<Assignable, List<ColumnReference>> targetColumnReferenceConsumer,
|
|
||||||
SqmInsertStatement<?> sqmStatement,
|
|
||||||
EntityPersister entityDescriptor,
|
|
||||||
TableGroup tableGroup,
|
|
||||||
SqmParameterResolutionConsumer parameterResolutionConsumer) {
|
|
||||||
this.parameterResolutionConsumer = parameterResolutionConsumer;
|
|
||||||
return visitInsertionTargetPaths( targetColumnReferenceConsumer, sqmStatement, entityDescriptor, tableGroup );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Predicate visitWhereClause(
|
public Predicate visitWhereClause(
|
||||||
SqmWhereClause sqmWhereClause,
|
SqmWhereClause sqmWhereClause,
|
||||||
Consumer<ColumnReference> restrictionColumnReferenceConsumer,
|
Consumer<ColumnReference> restrictionColumnReferenceConsumer,
|
||||||
|
|
|
@ -9,8 +9,6 @@ package org.hibernate.query.sqm.mutation.internal.cte;
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
@ -186,14 +184,6 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
);
|
);
|
||||||
final TableGroup insertingTableGroup = sqmConverter.getMutatingTableGroup();
|
final TableGroup insertingTableGroup = sqmConverter.getMutatingTableGroup();
|
||||||
|
|
||||||
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
|
||||||
parameterResolutions = Collections.emptyMap();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parameterResolutions = new IdentityHashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// visit the insertion target using our special converter, collecting
|
// visit the insertion target using our special converter, collecting
|
||||||
// information about the target paths
|
// information about the target paths
|
||||||
|
@ -201,7 +191,6 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
final int size = sqmStatement.getInsertionTargetPaths().size();
|
final int size = sqmStatement.getInsertionTargetPaths().size();
|
||||||
final List<Map.Entry<List<CteColumn>, Assignment>> targetPathColumns = new ArrayList<>( size );
|
final List<Map.Entry<List<CteColumn>, Assignment>> targetPathColumns = new ArrayList<>( size );
|
||||||
final List<CteColumn> targetPathCteColumns = new ArrayList<>( size );
|
final List<CteColumn> targetPathCteColumns = new ArrayList<>( size );
|
||||||
final Map<SqmParameter<?>, MappingModelExpressible<?>> paramTypeResolutions = new LinkedHashMap<>();
|
|
||||||
final NamedTableReference entityTableReference = new NamedTableReference(
|
final NamedTableReference entityTableReference = new NamedTableReference(
|
||||||
cteTable.getTableExpression(),
|
cteTable.getTableExpression(),
|
||||||
TemporaryTable.DEFAULT_ALIAS,
|
TemporaryTable.DEFAULT_ALIAS,
|
||||||
|
@ -236,14 +225,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
},
|
},
|
||||||
sqmInsertStatement,
|
sqmInsertStatement,
|
||||||
entityDescriptor,
|
entityDescriptor,
|
||||||
insertingTableGroup,
|
insertingTableGroup
|
||||||
(sqmParameter, mappingType, jdbcParameters) -> {
|
|
||||||
parameterResolutions.computeIfAbsent(
|
|
||||||
sqmParameter,
|
|
||||||
k -> new ArrayList<>( 1 )
|
|
||||||
).add( jdbcParameters );
|
|
||||||
paramTypeResolutions.put( sqmParameter, mappingType );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final boolean assignsId = targetPathCteColumns.contains( cteTable.getCteColumns().get( 0 ) );
|
final boolean assignsId = targetPathCteColumns.contains( cteTable.getCteColumns().get( 0 ) );
|
||||||
|
@ -604,7 +586,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
targetPathColumns,
|
targetPathColumns,
|
||||||
assignsId,
|
assignsId,
|
||||||
sqmConverter,
|
sqmConverter,
|
||||||
parameterResolutions,
|
sqmConverter.getJdbcParamsBySqmParam(),
|
||||||
factory
|
factory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -641,7 +623,7 @@ public class CteInsertHandler implements InsertHandler {
|
||||||
new SqmParameterMappingModelResolutionAccess() {
|
new SqmParameterMappingModelResolutionAccess() {
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public <T> MappingModelExpressible<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
public <T> MappingModelExpressible<T> getResolvedMappingModelType(SqmParameter<T> parameter) {
|
||||||
return (MappingModelExpressible<T>) paramTypeResolutions.get(parameter);
|
return (MappingModelExpressible<T>) sqmConverter.getSqmParameterMappingModelExpressibleResolutions().get( parameter );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
executionContext.getSession()
|
executionContext.getSession()
|
||||||
|
|
|
@ -134,20 +134,11 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
|
|
||||||
final TableGroup insertingTableGroup = converterDelegate.getMutatingTableGroup();
|
final TableGroup insertingTableGroup = converterDelegate.getMutatingTableGroup();
|
||||||
|
|
||||||
final Map<SqmParameter<?>, List<List<JdbcParameter>>> parameterResolutions;
|
|
||||||
if ( domainParameterXref.getSqmParameterCount() == 0 ) {
|
|
||||||
parameterResolutions = Collections.emptyMap();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
parameterResolutions = new IdentityHashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// visit the insertion target using our special converter, collecting
|
// visit the insertion target using our special converter, collecting
|
||||||
// information about the target paths
|
// information about the target paths
|
||||||
|
|
||||||
final List<Assignment> targetPathColumns = new ArrayList<>();
|
final List<Assignment> targetPathColumns = new ArrayList<>();
|
||||||
final Map<SqmParameter<?>, MappingModelExpressible<?>> paramTypeResolutions = new LinkedHashMap<>();
|
|
||||||
final NamedTableReference entityTableReference = new NamedTableReference(
|
final NamedTableReference entityTableReference = new NamedTableReference(
|
||||||
entityTable.getTableExpression(),
|
entityTable.getTableExpression(),
|
||||||
TemporaryTable.DEFAULT_ALIAS,
|
TemporaryTable.DEFAULT_ALIAS,
|
||||||
|
@ -162,14 +153,7 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
},
|
},
|
||||||
sqmInsertStatement,
|
sqmInsertStatement,
|
||||||
entityDescriptor,
|
entityDescriptor,
|
||||||
insertingTableGroup,
|
insertingTableGroup
|
||||||
(sqmParameter, mappingType, jdbcParameters) -> {
|
|
||||||
parameterResolutions.computeIfAbsent(
|
|
||||||
sqmParameter,
|
|
||||||
k -> new ArrayList<>( 1 )
|
|
||||||
).add( jdbcParameters );
|
|
||||||
paramTypeResolutions.put( sqmParameter, mappingType );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -329,9 +313,9 @@ public class TableBasedInsertHandler implements InsertHandler {
|
||||||
tableReferenceByAlias,
|
tableReferenceByAlias,
|
||||||
targetPathColumns,
|
targetPathColumns,
|
||||||
insertStatement,
|
insertStatement,
|
||||||
parameterResolutions,
|
converterDelegate.getJdbcParamsBySqmParam(),
|
||||||
sessionUidParameter,
|
sessionUidParameter,
|
||||||
paramTypeResolutions,
|
converterDelegate.getSqmParameterMappingModelExpressibleResolutions(),
|
||||||
executionContext
|
executionContext
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue