From 5631a702a7ded27aa878c99365749f11fac6763c Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 19 Sep 2019 15:13:50 -0500 Subject: [PATCH] initial working dynamic instantiation support; cleanup --- .../org/hibernate/boot/MetadataSources.java | 41 ++- .../internal/ManagedResourcesImpl.java | 7 + .../model/process/spi/ManagedResources.java | 4 + .../process/spi/MetadataBuildingProcess.java | 16 ++ .../metamodel/model/domain/JpaMetamodel.java | 2 + .../domain/internal/JpaMetamodelImpl.java | 5 + .../FullyQualifiedReflectivePathTerminal.java | 5 - .../hql/internal/SemanticQueryBuilder.java | 14 +- .../sqm/sql/BaseSqmToSqlAstConverter.java | 40 ++- .../query/sqm/sql/SqmToSqlAstConverter.java | 3 + .../BasicValuedPathInterpretation.java | 71 ++--- .../EmbeddableValuedPathInterpretation.java | 60 ++--- .../internal/SqmExpressionInterpretation.java | 34 --- .../internal/SqmParameterInterpretation.java | 41 +-- .../sql/internal/SqmPathInterpretation.java | 66 +---- .../internal/SqmSelectToSqlAstConverter.java | 9 +- .../internal/SqmSelectableInterpretation.java | 20 -- .../query/sqm/sql/internal/SqmSqlHelper.java | 36 --- .../sql/internal/SqmTupleInterpretation.java | 57 ++++ .../expression/AbstractSqmExpression.java | 5 - .../sqm/tree/expression/SqmEnumLiteral.java | 5 - .../sqm/tree/expression/SqmExpression.java | 3 +- .../sqm/tree/expression/SqmFieldLiteral.java | 5 - .../query/sqm/tree/expression/SqmLiteral.java | 18 -- .../query/sqm/tree/expression/SqmTuple.java | 47 +--- .../query/sqm/tree/from/SqmRoot.java | 18 -- .../sqm/tree/select/SqmSelectableNode.java | 11 +- .../query/sqm/tree/select/SqmSubQuery.java | 7 +- .../sql/ast/spi/JdbcLiteralFormatter.java | 2 + .../ast/tree/expression/AbstractLiteral.java | 57 +++- .../sql/ast/tree/expression/QueryLiteral.java | 4 +- .../sql/ast/tree/from/StandardTableGroup.java | 9 - .../sql/ast/tree/from/TableGroup.java | 4 +- .../instantiation/ArgumentDomainResult.java | 6 +- .../instantiation/DynamicInstantiation.java | 246 +++++++++--------- .../sql/NVarcharTypeDescriptor.java | 8 + .../descriptor/sql/VarcharTypeDescriptor.java | 8 + .../test/metamodel/mapping/SmokeTests.java | 8 + .../orm/test/sql/ast/SmokeTests.java | 49 ---- .../orm/test/sql/exec/SmokeTests.java | 190 +++++++++++++- .../testing/orm/junit/DomainModel.java | 7 + .../orm/junit/DomainModelExtension.java | 8 + 42 files changed, 662 insertions(+), 594 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmExpressionInterpretation.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectableInterpretation.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSqlHelper.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmTupleInterpretation.java diff --git a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java index fcac04652d..de68078d28 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java @@ -14,12 +14,14 @@ import java.io.Serializable; import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; +import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.jar.JarFile; import java.util.zip.ZipEntry; - import javax.xml.transform.dom.DOMSource; import org.hibernate.HibernateException; @@ -41,6 +43,7 @@ import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.SerializationException; + import org.w3c.dom.Document; /** @@ -64,6 +67,8 @@ public class MetadataSources implements Serializable { private LinkedHashSet annotatedClassNames = new LinkedHashSet<>(); private LinkedHashSet annotatedPackages = new LinkedHashSet<>(); + private Map> extraQueryImports; + public MetadataSources() { this( new BootstrapServiceRegistryBuilder().build() ); } @@ -111,6 +116,10 @@ public class MetadataSources implements Serializable { return annotatedClassNames; } + public Map> getExtraQueryImports() { + return extraQueryImports; + } + public ServiceRegistry getServiceRegistry() { return serviceRegistry; } @@ -196,6 +205,16 @@ public class MetadataSources implements Serializable { return this; } + /** + * Var-arg form of {@link #addAnnotatedClass} + */ + public MetadataSources addAnnotatedClasses(Class... annotatedClasses) { + if ( annotatedClasses != null && annotatedClasses.length > 0 ) { + Collections.addAll( this.annotatedClasses, annotatedClasses ); + } + return this; + } + /** * Read metadata from the annotations attached to the given class. The important * distinction here is that the {@link Class} will not be accessed until later @@ -210,6 +229,26 @@ public class MetadataSources implements Serializable { return this; } + /** + * Var-arg form of {@link #addAnnotatedClassName} + */ + public MetadataSources addAnnotatedClassNames(String... annotatedClassNames) { + if ( annotatedClassNames != null && annotatedClassNames.length > 0 ) { + Collections.addAll( this.annotatedClassNames, annotatedClassNames ); + } + return this; + } + + public MetadataSources addQueryImport(String importedName, Class target) { + if ( extraQueryImports == null ) { + extraQueryImports = new HashMap<>(); + } + + extraQueryImports.put( importedName, target ); + + return this; + } + /** * Read package-level metadata. * diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java index ac1502d00b..e4b0dc1af8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ManagedResourcesImpl.java @@ -30,6 +30,7 @@ public class ManagedResourcesImpl implements ManagedResources { private Set annotatedClassNames = new LinkedHashSet<>(); private Set annotatedPackageNames = new LinkedHashSet<>(); private List mappingFileBindings = new ArrayList<>(); + private Map> extraQueryImports; public static ManagedResourcesImpl baseline(MetadataSources sources, BootstrapContext bootstrapContext) { final ManagedResourcesImpl impl = new ManagedResourcesImpl(); @@ -38,6 +39,7 @@ public class ManagedResourcesImpl implements ManagedResources { impl.annotatedClassNames.addAll( sources.getAnnotatedClassNames() ); impl.annotatedPackageNames.addAll( sources.getAnnotatedPackages() ); impl.mappingFileBindings.addAll( sources.getXmlBindings() ); + impl.extraQueryImports = sources.getExtraQueryImports(); return impl; } @@ -69,6 +71,11 @@ public class ManagedResourcesImpl implements ManagedResources { return Collections.unmodifiableList( mappingFileBindings ); } + @Override + public Map> getExtraQueryImports() { + return extraQueryImports; + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // package private diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/ManagedResources.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/ManagedResources.java index 0318791ec8..e2a7b7aeb5 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/ManagedResources.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/ManagedResources.java @@ -7,6 +7,8 @@ package org.hibernate.boot.model.process.spi; import java.util.Collection; +import java.util.Map; +import java.util.Set; import org.hibernate.boot.AttributeConverterInfo; import org.hibernate.boot.jaxb.spi.Binding; @@ -66,4 +68,6 @@ public interface ManagedResources { * @return The list of bindings for all known XML mapping files. */ Collection getXmlMappingBindings(); + + Map> getExtraQueryImports(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java index 1fd72ee659..c7b23cb3d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java @@ -8,6 +8,7 @@ package org.hibernate.boot.model.process.spi; import java.util.Collection; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.hibernate.boot.MetadataSources; @@ -304,9 +305,24 @@ public class MetadataBuildingProcess { } } + applyExtraQueryImports( managedResources, metadataCollector ); + return metadataCollector.buildMetadataInstance( rootMetadataBuildingContext ); } + private static void applyExtraQueryImports( + ManagedResources managedResources, + InFlightMetadataCollectorImpl metadataCollector) { + final Map> extraQueryImports = managedResources.getExtraQueryImports(); + if ( extraQueryImports == null || extraQueryImports.isEmpty() ) { + return; + } + + for ( Map.Entry> entry : extraQueryImports.entrySet() ) { + metadataCollector.addImport( entry.getKey(), entry.getValue().getName() ); + } + } + // todo (7.0) : buildJandexInitializer // private static JandexInitManager buildJandexInitializer( // MetadataBuildingOptions options, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/JpaMetamodel.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/JpaMetamodel.java index 4574c07198..9910eae93e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/JpaMetamodel.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/JpaMetamodel.java @@ -81,6 +81,8 @@ public interface JpaMetamodel extends javax.persistence.metamodel.Metamodel { void visitEmbeddables(Consumer> action); + String qualifyImportableName(String queryName); + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Covariant returns diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java index 62e5f430fe..e6b7140eb6 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java @@ -269,6 +269,11 @@ public class JpaMetamodelImpl implements JpaMetamodel { return results; } + @Override + public String qualifyImportableName(String queryName) { + return resolveImportedName( queryName ); + } + private String resolveImportedName(String name) { String result = nameToImportNameMap.get( name ); if ( result == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java index 830a8bc4de..4f39d2e38d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java @@ -238,9 +238,4 @@ public class FullyQualifiedReflectivePathTerminal public NodeBuilder nodeBuilder() { return null; } - - @Override - public SqmExpressable getExpressableType() { - return expressableType; - } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java index de2efb9152..de4e71208b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java @@ -570,11 +570,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre else { final String className = ctx.dynamicInstantiationTarget().dotIdentifierSequence().getText(); try { - final Class targetJavaType = classForName( className ); - final JavaTypeDescriptor jtd = creationContext.getJpaMetamodel() - .getTypeConfiguration() - .getJavaTypeDescriptorRegistry() - .resolveDescriptor( targetJavaType ); + final JavaTypeDescriptor jtd = resolveInstantiationTargetJtd( className ); dynamicInstantiation = SqmDynamicInstantiation.forClassInstantiation( jtd, creationContext.getNodeBuilder() @@ -592,6 +588,14 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre return dynamicInstantiation; } + private JavaTypeDescriptor resolveInstantiationTargetJtd(String className) { + final Class targetJavaType = classForName( creationContext.getJpaMetamodel().qualifyImportableName( className ) ); + return creationContext.getJpaMetamodel() + .getTypeConfiguration() + .getJavaTypeDescriptorRegistry() + .resolveDescriptor( targetJavaType ); + } + private Class classForName(String className) { return creationContext.getServiceRegistry().getService( ClassLoaderService.class ).classForName( className ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 0e26f80def..d7dedc57f8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -20,7 +20,7 @@ import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.internal.util.collections.Stack; import org.hibernate.internal.util.collections.StandardStack; -import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; +import org.hibernate.metamodel.mapping.BasicValuedMapping; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.metamodel.model.domain.EmbeddableDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; @@ -35,12 +35,12 @@ import org.hibernate.query.sqm.SqmExpressable; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.function.SqmFunction; import org.hibernate.query.sqm.internal.DomainParameterXref; +import org.hibernate.query.sqm.internal.SqmMappingModelHelper; import org.hibernate.query.sqm.spi.BaseSemanticQueryWalker; import org.hibernate.query.sqm.spi.JdbcParameterBySqmParameterAccess; import org.hibernate.query.sqm.sql.internal.BasicValuedPathInterpretation; import org.hibernate.query.sqm.sql.internal.EmbeddableValuedPathInterpretation; import org.hibernate.query.sqm.sql.internal.SqlAstQuerySpecProcessingStateImpl; -import org.hibernate.query.sqm.sql.internal.SqmExpressionInterpretation; import org.hibernate.query.sqm.sql.internal.SqmParameterInterpretation; import org.hibernate.query.sqm.sql.internal.SqmPathInterpretation; import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement; @@ -614,8 +614,12 @@ public abstract class BaseSqmToSqlAstConverter // General expressions @Override - public SqmExpressionInterpretation visitLiteral(SqmLiteral literal) { - return literal; + public Expression visitLiteral(SqmLiteral literal) { + return new QueryLiteral( + literal.getLiteralValue(), + (BasicValuedMapping) SqmMappingModelHelper.resolveMappingModelExpressable( literal, this ), + getCurrentClauseStack().getCurrent() + ); } private final Map> jdbcParamsBySqmParam = new IdentityHashMap<>(); @@ -627,12 +631,12 @@ public abstract class BaseSqmToSqlAstConverter } @Override - public SqmExpressionInterpretation visitNamedParameterExpression(SqmNamedParameter expression) { + public Expression visitNamedParameterExpression(SqmNamedParameter expression) { return consumeSqmParameter( expression ); } - private SqmExpressionInterpretation consumeSqmParameter(SqmParameter sqmParameter) { + private Expression consumeSqmParameter(SqmParameter sqmParameter) { final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter ); final List jdbcParametersForSqm = new ArrayList<>(); @@ -1242,7 +1246,7 @@ public abstract class BaseSqmToSqlAstConverter public Object visitEnumLiteral(SqmEnumLiteral sqmEnumLiteral) { return new QueryLiteral( sqmEnumLiteral.getEnumValue(), - determineValueMapping( sqmEnumLiteral ), + (BasicValuedMapping) determineValueMapping( sqmEnumLiteral ), getCurrentClauseStack().getCurrent() ); } @@ -1251,7 +1255,7 @@ public abstract class BaseSqmToSqlAstConverter public Object visitFieldLiteral(SqmFieldLiteral sqmFieldLiteral) { return new QueryLiteral( sqmFieldLiteral.getValue(), - determineValueMapping( sqmFieldLiteral ), + (BasicValuedMapping) determineValueMapping( sqmFieldLiteral ), getCurrentClauseStack().getCurrent() ); } @@ -1322,11 +1326,7 @@ public abstract class BaseSqmToSqlAstConverter final Expression lhs; try { - lhs = ( (SqmExpressionInterpretation) predicate.getLeftHandExpression().accept( this ) ).toSqlExpression( - getCurrentClauseStack().getCurrent(), - this, - this - ); + lhs = (Expression) predicate.getLeftHandExpression().accept( this ); } finally { inferableTypeAccessStack.pop(); @@ -1336,11 +1336,7 @@ public abstract class BaseSqmToSqlAstConverter final Expression rhs; try { - rhs = ( (SqmExpressionInterpretation) predicate.getRightHandExpression().accept( this ) ).toSqlExpression( - getCurrentClauseStack().getCurrent(), - this, - this - ); + rhs = (Expression) predicate.getRightHandExpression().accept( this ); } finally { inferableTypeAccessStack.pop(); @@ -1472,13 +1468,7 @@ public abstract class BaseSqmToSqlAstConverter domainParameterXref.addExpansion( domainParam, sqmParameter, sqmParamToConsume ); } - inListPredicate.addExpression( - consumeSqmParameter( sqmParamToConsume ).toSqlExpression( - getCurrentClauseStack().getCurrent(), - this, - this - ) - ); + inListPredicate.addExpression( consumeSqmParameter( sqmParamToConsume ) ); } } finally { diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmToSqlAstConverter.java index a6a6185279..8ac26dc88f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmToSqlAstConverter.java @@ -6,8 +6,10 @@ */ package org.hibernate.query.sqm.sql; +import org.hibernate.internal.util.collections.Stack; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.sql.SqlAstCreationState; +import org.hibernate.sql.ast.Clause; /** * Specialized SemanticQueryWalker (SQM visitor) for producing SQL AST. @@ -15,4 +17,5 @@ import org.hibernate.query.sqm.sql.SqlAstCreationState; * @author Steve Ebersole */ public interface SqmToSqlAstConverter extends SemanticQueryWalker, SqlAstCreationState { + Stack getCurrentClauseStack(); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java index 8b74749d40..c8e54c5cd7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java @@ -10,15 +10,16 @@ import java.util.function.Consumer; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.query.NavigablePath; +import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.sqm.SemanticQueryWalker; -import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.internal.SqmMappingModelHelper; import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; +import org.hibernate.query.sqm.sql.SqlExpressionResolver; import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath; -import org.hibernate.sql.ast.Clause; +import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.spi.SqlAstCreationContext; +import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.update.Assignment; @@ -44,45 +45,63 @@ public class BasicValuedPathInterpretation implements AssignableSqmPathInterp null ); - return new BasicValuedPathInterpretation<>( sqmPath, mapping, tableGroup ); + final ColumnReference columnReference = (ColumnReference) sqlAstCreationState.getSqlExpressionResolver().resolveSqlExpression( + SqlExpressionResolver.createColumnReferenceKey( + mapping.getContainingTableExpression(), + mapping.getMappedColumnExpression() + ), + sacs -> new ColumnReference( + mapping.getMappedColumnExpression(), + tableGroup.resolveTableReference( mapping.getContainingTableExpression() ) + .getIdentificationVariable(), + mapping.getJdbcMapping(), + sqlAstCreationState.getCreationContext().getSessionFactory() + ) + ); + + return new BasicValuedPathInterpretation<>( columnReference, sqmPath, mapping, tableGroup ); } + private final ColumnReference columnReference; + private final SqmBasicValuedSimplePath sqmPath; private final BasicValuedModelPart mapping; private final TableGroup tableGroup; - private Expression expression; - private BasicValuedPathInterpretation( + ColumnReference columnReference, SqmBasicValuedSimplePath sqmPath, BasicValuedModelPart mapping, TableGroup tableGroup) { + assert columnReference != null; + this.columnReference = columnReference; + + assert sqmPath != null; this.sqmPath = sqmPath; + + assert mapping != null; this.mapping = mapping; + + assert tableGroup != null; this.tableGroup = tableGroup; + + } @Override - public NavigablePath getNavigablePath() { - return sqmPath.getNavigablePath(); + public SqmPath getInterpretedSqmPath() { + return sqmPath; } @Override - public SqmPathSource getSqmPathSource() { - return sqmPath.getReferencedPathSource(); + public ModelPart getExpressionType() { + return mapping; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // DomainResultProducer - @Override - public DomainResultProducer getDomainResultProducer( - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - return this; - } - @Override public DomainResult createDomainResult( String resultVariable, @@ -95,17 +114,6 @@ public class BasicValuedPathInterpretation implements AssignableSqmPathInterp mapping.applySqlSelections( getNavigablePath(), tableGroup, creationState ); } - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // SqmExpressionInterpretation - - @Override - public Expression toSqlExpression( - Clause clause, SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - throw new NotYetImplementedFor6Exception( getClass() ); - } - @Override public void applySqlAssignments( Expression newValueExpression, @@ -115,6 +123,11 @@ public class BasicValuedPathInterpretation implements AssignableSqmPathInterp throw new NotYetImplementedFor6Exception( getClass() ); } + @Override + public void accept(SqlAstWalker sqlTreeWalker) { + columnReference.accept( sqlTreeWalker ); + } + @Override public String toString() { return "BasicValuedPathInterpretation(" + sqmPath.getNavigablePath().getFullPath() + ')'; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java index 19af98b848..3d81379a36 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java @@ -10,15 +10,15 @@ import java.util.function.Consumer; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; -import org.hibernate.query.NavigablePath; +import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.sqm.SemanticQueryWalker; -import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.internal.SqmMappingModelHelper; import org.hibernate.query.sqm.sql.SqlAstCreationState; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath; -import org.hibernate.sql.ast.Clause; +import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.spi.SqlAstCreationContext; +import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.update.Assignment; @@ -28,59 +28,67 @@ import org.hibernate.sql.results.spi.DomainResultCreationState; /** * @author Steve Ebersole */ -public class EmbeddableValuedPathInterpretation implements AssignableSqmPathInterpretation, DomainResultProducer { +public class EmbeddableValuedPathInterpretation implements AssignableSqmPathInterpretation { /** * Static factory */ public static EmbeddableValuedPathInterpretation from( SqmEmbeddedValuedSimplePath sqmPath, - SqlAstCreationState sqlAstCreationState, + SqmToSqlAstConverter converter, SemanticQueryWalker sqmWalker) { - final TableGroup tableGroup = SqmMappingModelHelper.resolveLhs( sqmPath.getNavigablePath(), sqlAstCreationState ); - tableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), sqlAstCreationState ); + final TableGroup tableGroup = SqmMappingModelHelper.resolveLhs( sqmPath.getNavigablePath(), converter ); + tableGroup.getModelPart().prepareAsLhs( sqmPath.getNavigablePath(), converter ); final EmbeddableValuedModelPart mapping = (EmbeddableValuedModelPart) tableGroup.getModelPart().findSubPart( sqmPath.getReferencedPathSource().getPathName(), null ); - return new EmbeddableValuedPathInterpretation<>( sqmPath, mapping, tableGroup ); + return new EmbeddableValuedPathInterpretation<>( + mapping.toSqlExpression( + tableGroup, + converter.getCurrentClauseStack().getCurrent(), + converter, + converter + ), + sqmPath, + mapping, + tableGroup + ); } + private final Expression sqlExpression; + private final SqmEmbeddedValuedSimplePath sqmPath; private final EmbeddableValuedModelPart mapping; private final TableGroup tableGroup; public EmbeddableValuedPathInterpretation( + Expression sqlExpression, SqmEmbeddedValuedSimplePath sqmPath, EmbeddableValuedModelPart mapping, TableGroup tableGroup) { + this.sqlExpression = sqlExpression; this.sqmPath = sqmPath; this.mapping = mapping; this.tableGroup = tableGroup; } @Override - public NavigablePath getNavigablePath() { - return sqmPath.getNavigablePath(); + public SqmPath getInterpretedSqmPath() { + return sqmPath; } @Override - public SqmPathSource getSqmPathSource() { - return sqmPath.getReferencedPathSource(); + public ModelPart getExpressionType() { + return mapping; } - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // DomainResultProducer - @Override - public DomainResultProducer getDomainResultProducer( - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - return this; + public void accept(SqlAstWalker sqlTreeWalker) { + sqlExpression.accept( sqlTreeWalker ); } @Override @@ -93,18 +101,6 @@ public class EmbeddableValuedPathInterpretation implements AssignableSqmPathI mapping.applySqlSelections( getNavigablePath(), tableGroup, creationState ); } - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // SqmPathInterpretation - - @Override - public Expression toSqlExpression( - Clause clause, - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - return mapping.toSqlExpression( tableGroup, clause, walker, sqlAstCreationState ); - } - @Override public void applySqlAssignments( Expression newValueExpression, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmExpressionInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmExpressionInterpretation.java deleted file mode 100644 index a0cb6b27d2..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmExpressionInterpretation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.query.sqm.sql.internal; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.query.sqm.SqmExpressable; -import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; -import org.hibernate.sql.ast.Clause; -import org.hibernate.sql.ast.tree.expression.Expression; - -/** - * The interpretation of an SqmExpression as part of the SQM -> SQL conversion. - * - * Allows multi-column navigable references to be used anywhere a (SqlExpression) - * can be. The trick is to properly define methods on this interface for how the - * thing should be rendered into the SQL AST. - * - * @author Steve Ebersole - */ -public interface SqmExpressionInterpretation extends SqmSelectableInterpretation { - SqmExpressable getExpressableType(); - - default Expression toSqlExpression( - Clause clause, - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - throw new NotYetImplementedFor6Exception( getClass() ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java index ae56c1d0f4..bacb710c42 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java @@ -9,13 +9,8 @@ package org.hibernate.query.sqm.sql.internal; import java.util.List; import org.hibernate.metamodel.mapping.MappingModelExpressable; -import org.hibernate.metamodel.model.domain.internal.DomainModelHelper; -import org.hibernate.query.SemanticException; -import org.hibernate.query.sqm.SqmExpressable; -import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.ast.Clause; +import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.SqlTuple; import org.hibernate.sql.exec.spi.JdbcParameter; @@ -23,44 +18,34 @@ import org.hibernate.sql.exec.spi.JdbcParameter; /** * @author Steve Ebersole */ -public class SqmParameterInterpretation implements SqmExpressionInterpretation { +public class SqmParameterInterpretation implements Expression { private final SqmParameter sqmParameter; - private final List jdbcParameters; private final MappingModelExpressable valueMapping; + private final Expression resolvedExpression; + public SqmParameterInterpretation( SqmParameter sqmParameter, List jdbcParameters, MappingModelExpressable valueMapping) { + this.sqmParameter = sqmParameter; this.valueMapping = valueMapping; + assert jdbcParameters != null; assert jdbcParameters.size() > 0; - this.sqmParameter = sqmParameter; - this.jdbcParameters = jdbcParameters; + this.resolvedExpression = jdbcParameters.size() == 1 + ? jdbcParameters.get( 0 ) + : new SqlTuple( jdbcParameters, valueMapping ); } @Override - public SqmExpressable getExpressableType() { - return sqmParameter.getExpressableType(); + public void accept(SqlAstWalker sqlTreeWalker) { + resolvedExpression.accept( sqlTreeWalker ); } @Override - public Expression toSqlExpression( - Clause clause, - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - if ( jdbcParameters.size() == 1 ) { - return jdbcParameters.get( 0 ); - } - - return new SqlTuple( jdbcParameters, valueMapping ); - } - - @Override - public DomainResultProducer getDomainResultProducer( - SqmToSqlAstConverter walker, - SqlAstCreationState sqlAstCreationState) { - throw new SemanticException( "SqmParameter parameter cannot be a DomainResult" ); + public MappingModelExpressable getExpressionType() { + return valueMapping; } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmPathInterpretation.java index dce8213c7b..d5c980e641 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmPathInterpretation.java @@ -6,68 +6,26 @@ */ package org.hibernate.query.sqm.sql.internal; -import java.util.List; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.metamodel.model.domain.internal.BasicSqmPathSource; +import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.NavigablePath; -import org.hibernate.query.sqm.SqmPathSource; -import org.hibernate.query.sqm.sql.ConversionException; -import org.hibernate.query.sqm.sql.SqlAstCreationState; +import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.tree.expression.Expression; -import org.hibernate.sql.ast.tree.expression.SqlTuple; -import org.hibernate.sql.ast.tree.from.TableGroup; /** - * todo (6.0) : consider having `SqmPathInterpretation` extend `org.hibernate.sql.ast.tree.expression.Expression`. - * - Basic paths would logically resolve to a `ColumnReference` - * - Composite and entity-valued paths would logically resolve to a `SqlTuple` + * Interpretation of a {@link SqmPath} as part of the translation to SQL AST + * + * @see org.hibernate.query.sqm.sql.SqmToSqlAstConverter + * @see #getInterpretedSqmPath * * @author Steve Ebersole */ -public interface SqmPathInterpretation extends SqmExpressionInterpretation { - NavigablePath getNavigablePath(); - - @Override - default SqmPathSource getExpressableType() { - return getSqmPathSource(); +public interface SqmPathInterpretation extends Expression, DomainResultProducer { + default NavigablePath getNavigablePath() { + return getInterpretedSqmPath().getNavigablePath(); } - SqmPathSource getSqmPathSource(); + SqmPath getInterpretedSqmPath(); -// @Override -// default Expression toSqlExpression(SqlAstCreationState sqlAstCreationState) { -// throw new NotYetImplementedFor6Exception( getClass() ); -// final TableGroup tableGroup; -// -// if ( getSqmPathSource() instanceof BasicSqmPathSource ) { -// // maybe we should register the LHS TableGroup for the basic value -// // under its NavigablePath, similar to what we do for embeddables -// tableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( getNavigablePath().getParent() ); -// } -// else { -// // for embeddable-, entity- and plural-valued Navigables we maybe do not have a TableGroup -// final TableGroup thisTableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( getNavigablePath() ); -// if ( thisTableGroup != null ) { -// tableGroup = thisTableGroup; -// } -// else { -// final NavigablePath lhsNavigablePath = getNavigablePath().getParent(); -// if ( lhsNavigablePath == null ) { -// throw new ConversionException( "Could not find TableGroup to use - " + getNavigablePath().getFullPath() ); -// } -// tableGroup = sqlAstCreationState.getFromClauseAccess().findTableGroup( lhsNavigablePath ); -// } -// } -// -// sqlAstCreationState.getCreationContext().getDomainModel().resolveMappingExpressable( ) -// -// final List list = getNavigable().resolveColumnReferences( tableGroup, sqlAstCreationState ); -// if ( list.size() == 1 ) { -// assert list.get( 0 ) instanceof Expression; -// return (Expression) list.get( 0 ); -// } -// -// return new SqlTuple( list, sqlAstCreationState.getJdbcMapping() ); -// } + @Override + ModelPart getExpressionType(); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectToSqlAstConverter.java index 19848d0d6e..9338cf1094 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectToSqlAstConverter.java @@ -13,7 +13,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Supplier; import org.hibernate.HibernateException; import org.hibernate.LockMode; @@ -32,10 +31,6 @@ import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.tree.expression.JpaCriteriaParameter; -import org.hibernate.query.sqm.tree.expression.SqmJpaCriteriaParameterWrapper; -import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.results.internal.domain.instantiation.DynamicInstantiation; import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType; import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; import org.hibernate.query.sqm.tree.select.SqmDynamicInstantiation; @@ -53,6 +48,7 @@ import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.results.internal.domain.instantiation.DynamicInstantiation; import org.hibernate.sql.results.spi.CircularFetchDetector; import org.hibernate.sql.results.spi.DomainResult; import org.hibernate.sql.results.spi.DomainResultCreationState; @@ -141,8 +137,7 @@ public class SqmSelectToSqlAstConverter } private DomainResultProducer resolveDomainResultProducer(SqmSelection sqmSelection) { - SqmSelectableInterpretation interpretation = (SqmSelectableInterpretation) sqmSelection.getSelectableNode().accept( this ); - return interpretation.getDomainResultProducer( this, getSqlAstCreationState() ); + return (DomainResultProducer) sqmSelection.getSelectableNode().accept( this ); } private int fetchDepth = 0; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectableInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectableInterpretation.java deleted file mode 100644 index 3233146f42..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSelectableInterpretation.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.query.sqm.sql.internal; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; - -/** - * @author Steve Ebersole - */ -public interface SqmSelectableInterpretation { - default DomainResultProducer getDomainResultProducer(SqmToSqlAstConverter walker, SqlAstCreationState sqlAstCreationState) { - throw new NotYetImplementedFor6Exception( getClass() ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSqlHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSqlHelper.java deleted file mode 100644 index c6b1f63b18..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmSqlHelper.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.query.sqm.sql.internal; - -import org.hibernate.metamodel.model.domain.EmbeddableDomainType; -import org.hibernate.query.sqm.sql.ConversionException; -import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.tree.domain.SqmPath; -import org.hibernate.sql.ast.tree.from.TableGroup; - -/** - * @author Steve Ebersole - */ -@SuppressWarnings("WeakerAccess") -public class SqmSqlHelper { - private SqmSqlHelper() { - } - - public static TableGroup resolveTableGroup(SqmPath sqmPath, SqlAstCreationState creationState) { - SqmPath lhs = sqmPath; - while ( lhs.getReferencedPathSource().getSqmPathType() instanceof EmbeddableDomainType ) { - lhs = lhs.getLhs(); - } - - final TableGroup tableGroup = creationState.getFromClauseAccess().findTableGroup( lhs.getNavigablePath() ); - if ( tableGroup != null ) { - return tableGroup; - } - - throw new ConversionException( "Could not locate TableGroup to use : " + lhs.getNavigablePath() ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmTupleInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmTupleInterpretation.java new file mode 100644 index 0000000000..79b966a77d --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmTupleInterpretation.java @@ -0,0 +1,57 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.query.sqm.sql.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.metamodel.mapping.MappingModelExpressable; +import org.hibernate.query.sqm.SemanticQueryWalker; +import org.hibernate.query.sqm.internal.SqmMappingModelHelper; +import org.hibernate.query.sqm.sql.SqlAstCreationState; +import org.hibernate.query.sqm.tree.expression.SqmExpression; +import org.hibernate.query.sqm.tree.expression.SqmTuple; +import org.hibernate.sql.ast.tree.expression.Expression; +import org.hibernate.sql.ast.tree.expression.SqlTuple; + +/** + * @author Steve Ebersole + */ +public class SqmTupleInterpretation extends SqlTuple { + + public static SqmTupleInterpretation from( + SqmTuple sqmTuple, + SemanticQueryWalker walker, + SqlAstCreationState sqlAstCreationState) { + final List groupedSqlExpressions = new ArrayList<>(); + + for ( SqmExpression groupedExpression : sqmTuple.getGroupedExpressions() ) { + groupedSqlExpressions.add( (Expression) groupedExpression.accept( walker ) ); + } + + return new SqmTupleInterpretation<>( + sqmTuple, + groupedSqlExpressions, + SqmMappingModelHelper.resolveMappingModelExpressable( sqmTuple, sqlAstCreationState ) + ); + } + + private final SqmTuple interpretedSqmTuple; + + public SqmTupleInterpretation( + SqmTuple sqmTuple, + List expressions, + MappingModelExpressable valueMapping) { + + super( expressions, valueMapping ); + interpretedSqmTuple = sqmTuple; + } + + public SqmTuple getInterpretedSqmTuple() { + return interpretedSqmTuple; + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/AbstractSqmExpression.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/AbstractSqmExpression.java index 3b97618ae6..f80f6c53ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/AbstractSqmExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/AbstractSqmExpression.java @@ -31,11 +31,6 @@ public abstract class AbstractSqmExpression extends AbstractJpaSelection i super( type, criteriaBuilder ); } - @Override - public SqmExpressable getExpressableType() { - return getNodeType(); - } - @Override public final void applyInferableType(SqmExpressable type) { if ( type == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmEnumLiteral.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmEnumLiteral.java index 0bc4bd8e3f..7ec3e2369c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmEnumLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmEnumLiteral.java @@ -65,11 +65,6 @@ public class SqmEnumLiteral implements SqmExpression, SqmExpressable return referencedEnumTypeDescriptor; } - @Override - public SqmExpressable getExpressableType() { - return expressable; - } - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // SemanticPathPart diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java index 55599c7524..ebeb50bd5b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java @@ -16,7 +16,6 @@ import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.query.criteria.JpaExpression; import org.hibernate.query.sqm.SqmExpressable; -import org.hibernate.query.sqm.sql.internal.SqmExpressionInterpretation; import org.hibernate.query.sqm.tree.predicate.SqmPredicate; import org.hibernate.query.sqm.tree.select.SqmSelectableNode; @@ -29,7 +28,7 @@ import org.hibernate.query.sqm.tree.select.SqmSelectableNode; * * @author Steve Ebersole */ -public interface SqmExpression extends SqmSelectableNode, JpaExpression, SqmExpressionInterpretation { +public interface SqmExpression extends SqmSelectableNode, JpaExpression { /** * The expression's type. * diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java index 05695281df..22652caa5e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java @@ -77,11 +77,6 @@ public class SqmFieldLiteral implements SqmExpression, SqmExpressable, return value; } - @Override - public SqmExpressable getExpressableType() { - return expressable; - } - public JavaTypeDescriptor getFieldJavaTypeDescriptor() { return fieldJavaTypeDescriptor; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmLiteral.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmLiteral.java index f26026c65b..ba9f71009f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmLiteral.java @@ -9,13 +9,7 @@ package org.hibernate.query.sqm.tree.expression; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.SqmExpressable; -import org.hibernate.query.sqm.internal.SqmMappingModelHelper; -import org.hibernate.query.sqm.sql.SqlAstCreationState; -import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.Clause; -import org.hibernate.sql.ast.tree.expression.Expression; -import org.hibernate.sql.ast.tree.expression.QueryLiteral; /** * Represents a literal value in the sqm, e.g.