From 30bb01d0fa521a0ef7b7db9da44b5994f58a5ce4 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Fri, 18 Nov 2022 11:44:21 +0100 Subject: [PATCH] Revert removal of JavaType from SqlSelectionProducer#createSqlSelection --- .../query/results/ResultSetMappingSqlSelection.java | 2 ++ .../function/SelfRenderingFunctionSqlAstExpression.java | 7 ++++++- .../sql/internal/DiscriminatorPathInterpretation.java | 2 ++ .../sql/internal/SqlAstQueryPartProcessingStateImpl.java | 1 + .../org/hibernate/sql/ast/spi/SqlSelectionProducer.java | 6 +++++- .../hibernate/sql/ast/tree/expression/Expression.java | 8 +++++++- .../sql/ast/tree/from/DelegatingTableGroup.java | 9 ++++++++- .../sql/exec/internal/AbstractJdbcParameter.java | 8 +++++++- 8 files changed, 38 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java index 3eb6edf879..8dd6028825 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/ResultSetMappingSqlSelection.java @@ -16,6 +16,7 @@ import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.ValueExtractor; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -50,6 +51,7 @@ public class ResultSetMappingSqlSelection implements SqlSelection, Expression, S public SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SelfRenderingFunctionSqlAstExpression.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SelfRenderingFunctionSqlAstExpression.java index 33e8efa12e..af3036b146 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SelfRenderingFunctionSqlAstExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/function/SelfRenderingFunctionSqlAstExpression.java @@ -89,8 +89,13 @@ public class SelfRenderingFunctionSqlAstExpression public SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { - return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this ); + return new SqlSelectionImpl( + jdbcPosition, + valuesArrayPosition, + this + ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DiscriminatorPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DiscriminatorPathInterpretation.java index 70fab9366b..839c51d800 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DiscriminatorPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DiscriminatorPathInterpretation.java @@ -18,6 +18,7 @@ import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -52,6 +53,7 @@ public class DiscriminatorPathInterpretation extends AbstractSqmPathInterpretati public SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { return new ResultSetMappingSqlSelection( valuesArrayPosition, getDiscriminatorMapping() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQueryPartProcessingStateImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQueryPartProcessingStateImpl.java index a9889a15ea..2cd348fd66 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQueryPartProcessingStateImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQueryPartProcessingStateImpl.java @@ -124,6 +124,7 @@ public class SqlAstQueryPartProcessingStateImpl final SqlSelection sqlSelection = expression.createSqlSelection( valuesArrayPosition + 1, valuesArrayPosition, + javaType, typeConfiguration ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java index a038df9291..e2b0e868a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java @@ -7,6 +7,7 @@ package org.hibernate.sql.ast.spi; import org.hibernate.sql.results.jdbc.spi.RowProcessingState; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -15,12 +16,15 @@ import org.hibernate.type.spi.TypeConfiguration; public interface SqlSelectionProducer { /** * Create a SqlSelection for the given JDBC ResultSet position - * @param jdbcPosition The index position used to read values from JDBC + * + * @param jdbcPosition The index position used to read values from JDBC * @param valuesArrayPosition The position in our {@linkplain RowProcessingState#getJdbcValue(SqlSelection) "current JDBC values array"} + * @param javaType The descriptor for the Java type to read the value as * @param typeConfiguration The associated TypeConfiguration */ SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/Expression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/Expression.java index 4163c08ba6..c016ae83f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/Expression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/Expression.java @@ -11,6 +11,7 @@ import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelectionProducer; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.results.internal.SqlSelectionImpl; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -32,7 +33,12 @@ public interface Expression extends SqlAstNode, SqlSelectionProducer { default SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { - return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this ); + return new SqlSelectionImpl( + jdbcPosition, + valuesArrayPosition, + this + ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/DelegatingTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/DelegatingTableGroup.java index 8190b5c5cb..b9c6a041ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/DelegatingTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/DelegatingTableGroup.java @@ -18,6 +18,7 @@ import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -46,8 +47,14 @@ public abstract class DelegatingTableGroup implements TableGroup { public SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { - return getTableGroup().createSqlSelection( jdbcPosition, valuesArrayPosition, typeConfiguration ); + return getTableGroup().createSqlSelection( + jdbcPosition, + valuesArrayPosition, + javaType, + typeConfiguration + ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java index db94454e82..aa5dfbf798 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java @@ -25,6 +25,7 @@ import org.hibernate.sql.exec.spi.JdbcParameterBinder; import org.hibernate.sql.exec.spi.JdbcParameterBinding; import org.hibernate.sql.exec.spi.JdbcParameterBindings; import org.hibernate.sql.results.internal.SqlSelectionImpl; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; /** @@ -58,12 +59,17 @@ public abstract class AbstractJdbcParameter public SqlSelection createSqlSelection( int jdbcPosition, int valuesArrayPosition, + JavaType javaType, TypeConfiguration typeConfiguration) { // todo (6.0) : investigate "virtual" or "static" selections // - anything that is the same for each row always - parameter, literal, etc; // the idea would be to write the value directly into the JdbcValues array // and not generating a SQL selection in the query sent to DB - return new SqlSelectionImpl( jdbcPosition, valuesArrayPosition, this ); + return new SqlSelectionImpl( + jdbcPosition, + valuesArrayPosition, + this + ); } @Override