From 1cbbf9f50ad828747f7a5f8fb8bd7d30251c87a7 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 18 Oct 2023 17:46:41 +0200 Subject: [PATCH] HHH-17279 Get rid of MultiTableSqmMutationConverter#visitInsertionTargetPaths --- .../MultiTableSqmMutationConverter.java | 13 ---------- .../internal/cte/CteInsertHandler.java | 24 +++---------------- .../temptable/TableBasedInsertHandler.java | 22 +++-------------- 3 files changed, 6 insertions(+), 53 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java index 6e58861064..a2bc74ea3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java @@ -165,19 +165,6 @@ public class MultiTableSqmMutationConverter extends BaseSqmToSqlAstConverter> targetColumnReferenceConsumer, - SqmInsertStatement sqmStatement, - EntityPersister entityDescriptor, - TableGroup tableGroup, - SqmParameterResolutionConsumer parameterResolutionConsumer) { - this.parameterResolutionConsumer = parameterResolutionConsumer; - return visitInsertionTargetPaths( targetColumnReferenceConsumer, sqmStatement, entityDescriptor, tableGroup ); - } - public Predicate visitWhereClause( SqmWhereClause sqmWhereClause, Consumer restrictionColumnReferenceConsumer, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java index 0b0c7e753d..c8cefd8f74 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java @@ -9,8 +9,6 @@ package org.hibernate.query.sqm.mutation.internal.cte; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -186,14 +184,6 @@ public class CteInsertHandler implements InsertHandler { ); final TableGroup insertingTableGroup = sqmConverter.getMutatingTableGroup(); - final Map, List>> parameterResolutions; - if ( domainParameterXref.getSqmParameterCount() == 0 ) { - parameterResolutions = Collections.emptyMap(); - } - else { - parameterResolutions = new IdentityHashMap<>(); - } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // visit the insertion target using our special converter, collecting // information about the target paths @@ -201,7 +191,6 @@ public class CteInsertHandler implements InsertHandler { final int size = sqmStatement.getInsertionTargetPaths().size(); final List, Assignment>> targetPathColumns = new ArrayList<>( size ); final List targetPathCteColumns = new ArrayList<>( size ); - final Map, MappingModelExpressible> paramTypeResolutions = new LinkedHashMap<>(); final NamedTableReference entityTableReference = new NamedTableReference( cteTable.getTableExpression(), TemporaryTable.DEFAULT_ALIAS, @@ -236,14 +225,7 @@ public class CteInsertHandler implements InsertHandler { }, sqmInsertStatement, entityDescriptor, - insertingTableGroup, - (sqmParameter, mappingType, jdbcParameters) -> { - parameterResolutions.computeIfAbsent( - sqmParameter, - k -> new ArrayList<>( 1 ) - ).add( jdbcParameters ); - paramTypeResolutions.put( sqmParameter, mappingType ); - } + insertingTableGroup ); final boolean assignsId = targetPathCteColumns.contains( cteTable.getCteColumns().get( 0 ) ); @@ -604,7 +586,7 @@ public class CteInsertHandler implements InsertHandler { targetPathColumns, assignsId, sqmConverter, - parameterResolutions, + sqmConverter.getJdbcParamsBySqmParam(), factory ); @@ -641,7 +623,7 @@ public class CteInsertHandler implements InsertHandler { new SqmParameterMappingModelResolutionAccess() { @Override @SuppressWarnings("unchecked") public MappingModelExpressible getResolvedMappingModelType(SqmParameter parameter) { - return (MappingModelExpressible) paramTypeResolutions.get(parameter); + return (MappingModelExpressible) sqmConverter.getSqmParameterMappingModelExpressibleResolutions().get( parameter ); } }, executionContext.getSession() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/TableBasedInsertHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/TableBasedInsertHandler.java index 5b4eba867e..384ca3f74a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/TableBasedInsertHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/TableBasedInsertHandler.java @@ -134,20 +134,11 @@ public class TableBasedInsertHandler implements InsertHandler { final TableGroup insertingTableGroup = converterDelegate.getMutatingTableGroup(); - final Map, List>> parameterResolutions; - if ( domainParameterXref.getSqmParameterCount() == 0 ) { - parameterResolutions = Collections.emptyMap(); - } - else { - parameterResolutions = new IdentityHashMap<>(); - } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // visit the insertion target using our special converter, collecting // information about the target paths final List targetPathColumns = new ArrayList<>(); - final Map, MappingModelExpressible> paramTypeResolutions = new LinkedHashMap<>(); final NamedTableReference entityTableReference = new NamedTableReference( entityTable.getTableExpression(), TemporaryTable.DEFAULT_ALIAS, @@ -162,14 +153,7 @@ public class TableBasedInsertHandler implements InsertHandler { }, sqmInsertStatement, entityDescriptor, - insertingTableGroup, - (sqmParameter, mappingType, jdbcParameters) -> { - parameterResolutions.computeIfAbsent( - sqmParameter, - k -> new ArrayList<>( 1 ) - ).add( jdbcParameters ); - paramTypeResolutions.put( sqmParameter, mappingType ); - } + insertingTableGroup ); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -329,9 +313,9 @@ public class TableBasedInsertHandler implements InsertHandler { tableReferenceByAlias, targetPathColumns, insertStatement, - parameterResolutions, + converterDelegate.getJdbcParamsBySqmParam(), sessionUidParameter, - paramTypeResolutions, + converterDelegate.getSqmParameterMappingModelExpressibleResolutions(), executionContext ); }