From 163cc5331815a85b15c2f21d042991cf28ef5792 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 24 May 2019 11:21:47 -0500 Subject: [PATCH] 6 - SQM based on JPA type system --- .../model/domain/BasicDomainType.java | 3 +- .../hibernate/query/ParameterMetadata.java | 14 +- .../query/{criteria => }/PathException.java | 2 +- .../org/hibernate/query/criteria/JpaPath.java | 1 + .../hql/internal/SemanticQueryBuilder.java | 201 +++++++++------- .../query/hql/spi/HqlQueryImplementor.java | 24 ++ .../hibernate/query/named/package-info.java | 14 ++ .../named/spi/AbstractNamedQueryMemento.java | 172 ++++++++++++++ .../org/hibernate/query/named/spi/Helper.java | 222 ++++++++++++++++++ .../query/named/spi/NameableQuery.java | 19 ++ .../named/spi/NamedCallableQueryMemento.java | 31 +++ .../query/named/spi/NamedHqlQueryMemento.java | 28 +++ .../named/spi/NamedNativeQueryMemento.java | 31 +++ .../query/named/spi/NamedQueryMemento.java | 51 ++++ .../query/named/spi/ParameterMemento.java | 17 ++ .../query/named/spi/RowReaderMemento.java | 16 ++ .../spi/ParameterMetadataImplementor.java | 39 +++ .../query/spi/QueryParameterImplementor.java | 19 ++ .../hibernate/query/sqm/SqmPathSource.java | 3 + .../consume/spi/BaseSemanticQueryWalker.java | 4 +- .../sqm/consume/spi/SemanticQueryWalker.java | 4 +- .../sqm/produce/internal/SqmTreePrinter.java | 4 +- .../AbstractSqmSpecificPluralPartPath.java | 2 +- .../tree/domain/SqmAnyValuedSimplePath.java | 2 +- .../query/sqm/tree/domain/SqmBagJoin.java | 6 +- .../tree/domain/SqmBasicValuedSimplePath.java | 2 +- .../domain/SqmEmbeddedValuedSimplePath.java | 2 +- .../domain/SqmEntityValuedSimplePath.java | 2 +- .../SqmIndexedCollectionAccessPath.java | 2 +- .../query/sqm/tree/domain/SqmListJoin.java | 6 +- .../query/sqm/tree/domain/SqmMapJoin.java | 7 +- .../query/sqm/tree/domain/SqmPath.java | 2 +- .../domain/SqmPluralValuedSimplePath.java | 2 +- .../query/sqm/tree/domain/SqmSetJoin.java | 6 +- .../sqm/tree/domain/SqmSingularJoin.java | 7 +- .../sqm/tree/domain/SqmTreatedSimplePath.java | 2 +- .../expression/AbstractSqmExpression.java | 25 +- .../sqm/tree/expression/LiteralHelper.java | 4 - .../sqm/tree/expression/SqmCaseSearched.java | 2 +- ...izedEntityType.java => SqmEntityType.java} | 24 +- .../query/sqm/tree/from/SqmCrossJoin.java | 9 +- .../query/sqm/tree/from/SqmEntityJoin.java | 7 +- .../query/sqm/tree/from/SqmRoot.java | 2 +- .../DomainResultCreationException.java | 25 ++ .../sql/results/SqlResultsLogger.java | 35 +++ .../hibernate/sql/results/package-info.java | 11 + .../results/spi/AssemblerCreationState.java | 13 + .../sql/results/spi/DomainResult.java | 48 ++++ .../results/spi/DomainResultAssembler.java | 18 ++ .../spi/DomainResultCreationState.java | 13 + .../sql/results/spi/DomainResultProducer.java | 38 +++ .../sql/results/spi/Initializer.java | 17 ++ .../sql/results/spi/ResultSetMappingNode.java | 33 +++ 53 files changed, 1133 insertions(+), 160 deletions(-) rename hibernate-core/src/main/java/org/hibernate/query/{criteria => }/PathException.java (93%) create mode 100644 hibernate-core/src/main/java/org/hibernate/query/hql/spi/HqlQueryImplementor.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/package-info.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/AbstractNamedQueryMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/Helper.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/NameableQuery.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/NamedCallableQueryMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/NamedHqlQueryMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/NamedNativeQueryMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/NamedQueryMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/ParameterMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/named/spi/RowReaderMemento.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/spi/ParameterMetadataImplementor.java create mode 100644 hibernate-core/src/main/java/org/hibernate/query/spi/QueryParameterImplementor.java rename hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/{SqmParameterizedEntityType.java => SqmEntityType.java} (67%) create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/DomainResultCreationException.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/SqlResultsLogger.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/package-info.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/AssemblerCreationState.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResult.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultAssembler.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultCreationState.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultProducer.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/Initializer.java create mode 100644 hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultSetMappingNode.java diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/BasicDomainType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/BasicDomainType.java index c9b3a81480..7ae8188a2c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/BasicDomainType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/BasicDomainType.java @@ -17,7 +17,8 @@ import org.hibernate.query.sqm.SqmExpressable; * * @author Steve Ebersole */ -public interface BasicDomainType extends SimpleDomainType, BasicType, SqmExpressable { +public interface BasicDomainType + extends SimpleDomainType, BasicType, SqmExpressable, AllowableOutputParameterType, AllowableFunctionReturnType { @Override default PersistenceType getPersistenceType() { return PersistenceType.BASIC; diff --git a/hibernate-core/src/main/java/org/hibernate/query/ParameterMetadata.java b/hibernate-core/src/main/java/org/hibernate/query/ParameterMetadata.java index 3abda85ca9..8dbe8e4c87 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/ParameterMetadata.java +++ b/hibernate-core/src/main/java/org/hibernate/query/ParameterMetadata.java @@ -18,7 +18,7 @@ import org.hibernate.Incubating; * @author Steve Ebersole */ @Incubating -public interface ParameterMetadata

> { +public interface ParameterMetadata { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` // General purpose @@ -35,7 +35,7 @@ public interface ParameterMetadata

> { * * @throws IllegalArgumentException if no parameter is registered under that name */ - P getQueryParameter(String name); + QueryParameter getQueryParameter(String name); /** * Resolve the QueryParameter reference registered here under the @@ -45,7 +45,7 @@ public interface ParameterMetadata

> { * * @throws IllegalArgumentException if no parameter is registered under that label */ - P getQueryParameter(int positionLabel); + QueryParameter getQueryParameter(int positionLabel); /** * A deeper resolution attempt from a JPA parameter reference to Hibernate's @@ -54,19 +54,19 @@ public interface ParameterMetadata

> { * According to the spec, only Parameter references obtained from the provider * are valid. */ - P resolve(Parameter param); + QueryParameter resolve(Parameter param); /** * Is this parameter reference registered in this collection? */ - boolean containsReference(P parameter); + boolean containsReference(QueryParameter parameter); - Set

getRegistrations(); + Set> getRegistrations(); /** * General purpose visitation using functional */ - void visitRegistrations(Consumer

action); + void visitRegistrations(Consumer> action); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/PathException.java b/hibernate-core/src/main/java/org/hibernate/query/PathException.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/query/criteria/PathException.java rename to hibernate-core/src/main/java/org/hibernate/query/PathException.java index badf0e9a17..3952900962 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/PathException.java +++ b/hibernate-core/src/main/java/org/hibernate/query/PathException.java @@ -4,7 +4,7 @@ * 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.criteria; +package org.hibernate.query; import org.hibernate.HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPath.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPath.java index 65cb530b71..28e1450a2b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPath.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaPath.java @@ -10,6 +10,7 @@ import javax.persistence.criteria.Path; import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.NavigablePath; +import org.hibernate.query.PathException; /** * API extension to the JPA {@link Path} contract 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 09edaa8299..fadcec9664 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 @@ -23,22 +23,25 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.internal.util.collections.Stack; import org.hibernate.internal.util.collections.StandardStack; +import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.model.domain.AllowableFunctionReturnType; +import org.hibernate.metamodel.model.domain.BasicDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; -import org.hibernate.metamodel.model.domain.ListPersistentAttribute; +import org.hibernate.metamodel.model.domain.IdentifiableDomainType; +import org.hibernate.metamodel.model.domain.ManagedDomainType; import org.hibernate.metamodel.model.domain.MapPersistentAttribute; import org.hibernate.metamodel.model.domain.PluralPersistentAttribute; -import org.hibernate.metamodel.model.domain.SingularPersistentAttribute; import org.hibernate.query.BinaryArithmeticOperator; import org.hibernate.query.ComparisonOperator; +import org.hibernate.query.PathException; import org.hibernate.query.QueryLogger; +import org.hibernate.query.SemanticException; import org.hibernate.query.TrimSpec; import org.hibernate.query.UnaryArithmeticOperator; import org.hibernate.query.hql.DotIdentifierConsumer; import org.hibernate.query.sqm.LiteralNumberFormatException; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.ParsingException; -import org.hibernate.query.SemanticException; import org.hibernate.query.sqm.SqmExpressable; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.StrictJpaComplianceViolation; @@ -62,38 +65,26 @@ import org.hibernate.query.sqm.tree.SqmJoinType; import org.hibernate.query.sqm.tree.SqmStatement; import org.hibernate.query.sqm.tree.SqmTypedNode; import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement; -import org.hibernate.query.sqm.tree.domain.SqmBagJoin; import org.hibernate.query.sqm.tree.domain.SqmIndexedCollectionAccessPath; -import org.hibernate.query.sqm.tree.domain.SqmListJoin; import org.hibernate.query.sqm.tree.domain.SqmMapEntryReference; -import org.hibernate.query.sqm.tree.domain.SqmMapJoin; import org.hibernate.query.sqm.tree.domain.SqmMaxElementPath; import org.hibernate.query.sqm.tree.domain.SqmMaxIndexPath; import org.hibernate.query.sqm.tree.domain.SqmMinElementPath; import org.hibernate.query.sqm.tree.domain.SqmMinIndexPath; -import org.hibernate.query.sqm.tree.domain.SqmNavigableReference; import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.query.sqm.tree.domain.SqmPolymorphicRootDescriptor; -import org.hibernate.query.sqm.tree.domain.SqmSetJoin; -import org.hibernate.query.sqm.tree.domain.SqmSingularJoin; -import org.hibernate.query.sqm.tree.domain.SqmTreatedBagJoin; -import org.hibernate.query.sqm.tree.domain.SqmTreatedListJoin; -import org.hibernate.query.sqm.tree.domain.SqmTreatedMapJoin; import org.hibernate.query.sqm.tree.domain.SqmTreatedPath; -import org.hibernate.query.sqm.tree.domain.SqmTreatedRoot; -import org.hibernate.query.sqm.tree.domain.SqmTreatedSetJoin; -import org.hibernate.query.sqm.tree.domain.SqmTreatedSingularJoin; import org.hibernate.query.sqm.tree.expression.LiteralHelper; import org.hibernate.query.sqm.tree.expression.SqmBinaryArithmetic; import org.hibernate.query.sqm.tree.expression.SqmCaseSearched; import org.hibernate.query.sqm.tree.expression.SqmCaseSimple; import org.hibernate.query.sqm.tree.expression.SqmCollectionSize; +import org.hibernate.query.sqm.tree.expression.SqmEntityType; import org.hibernate.query.sqm.tree.expression.SqmExpression; import org.hibernate.query.sqm.tree.expression.SqmLiteral; import org.hibernate.query.sqm.tree.expression.SqmLiteralNull; import org.hibernate.query.sqm.tree.expression.SqmNamedParameter; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType; import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter; import org.hibernate.query.sqm.tree.expression.SqmUnaryOperation; import org.hibernate.query.sqm.tree.expression.function.SqmCastTarget; @@ -138,7 +129,6 @@ import org.hibernate.query.sqm.tree.select.SqmSelection; import org.hibernate.query.sqm.tree.select.SqmSortSpecification; import org.hibernate.query.sqm.tree.select.SqmSubQuery; import org.hibernate.query.sqm.tree.update.SqmUpdateStatement; -import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.jboss.logging.Logger; @@ -336,7 +326,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre log.debugf( "Generated implicit alias [%s] for INSERT target [%s]", alias, - targetType.getEntityName() + targetType.getHibernateEntityName() ); insertStatement.setSelectQuerySpec( visitQuerySpec( ctx.querySpec() ) ); @@ -480,7 +470,9 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre throw new SemanticException( "limit and offset clause require an order-by clause when used in sub-query" ); } + //noinspection unchecked sqmQuerySpec.setOffsetExpression( visitOffsetClause( ctx.offsetClause() ) ); + //noinspection unchecked sqmQuerySpec.setLimitExpression( visitLimitClause( ctx.limitClause() ) ); } @@ -493,6 +485,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre // the root and each non-fetched-join was selected. For now, here, we simply // select the root final SqmSelectClause selectClause = new SqmSelectClause( false, creationContext.getNodeBuilder() ); + //noinspection unchecked fromClause.visitRoots( sqmRoot -> selectClause.addSelection( new SqmSelection( sqmRoot, sqmRoot.getExplicitAlias(), creationContext.getNodeBuilder() ) @@ -530,6 +523,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre final String resultIdentifier = visitResultIdentifier( ctx.resultIdentifier() ); final SqmSelectableNode selectableNode = visitSelectableNode( ctx ); + //noinspection unchecked final SqmSelection selection = new SqmSelection( selectableNode, resultIdentifier, @@ -1034,6 +1028,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre join.setExplicitAlias( alias ); if ( join instanceof SqmEntityJoin ) { + //noinspection unchecked sqmRoot.addSqmJoin( join ); } else { @@ -1080,7 +1075,8 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre throw new UnsupportedOperationException(); } - public void consumeJpaCollectionJoin(HqlParser.JpaCollectionJoinContext ctx) { + @SuppressWarnings("WeakerAccess") + protected void consumeJpaCollectionJoin(HqlParser.JpaCollectionJoinContext ctx) { // todo (6.0) : this should always make sure the collection tables are joined // ideally via specialized DotIdentifierConsumer identifierConsumerStack.push( new BasicDotIdentifierConsumer( processingStateStack::getCurrent ) ); @@ -1252,6 +1248,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre listExpressions.add( listItemExpression ); } + //noinspection unchecked return new SqmInListPredicate( testExpression, listExpressions, creationContext.getNodeBuilder() ); } finally { @@ -1262,7 +1259,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre final HqlParser.SubQueryInListContext subQueryContext = (HqlParser.SubQueryInListContext) ctx.inList(); final SqmExpression subQueryExpression = (SqmExpression) subQueryContext.expression().accept( this ); - if ( !SqmSubQuery.class.isInstance( subQueryExpression ) ) { + if ( !(subQueryExpression instanceof SqmSubQuery) ) { throw new ParsingException( "Was expecting a SubQueryExpression, but found " + subQueryExpression.getClass().getSimpleName() + " : " + subQueryContext.expression().toString() @@ -1283,24 +1280,24 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre } @Override + @SuppressWarnings("unchecked") public Object visitEntityTypeExpression(HqlParser.EntityTypeExpressionContext ctx) { // can be one of 2 forms: // 1) TYPE( some.path ) // 2) TYPE( :someParam ) if ( ctx.entityTypeReference().parameter() != null ) { // we have form (2) - return new SqmParameterizedEntityType( + return new SqmEntityType( (SqmParameter) ctx.entityTypeReference().parameter().accept( this ), creationContext.getNodeBuilder() ); } else if ( ctx.entityTypeReference().path() != null ) { - final SqmNavigableReference binding = (SqmNavigableReference) ctx.entityTypeReference().path().accept( this ); - return binding.sqmAs( EntityValuedNavigable.class ) - .getEntityDescriptor() - .getHierarchy() - .getDiscriminatorDescriptor() - .createSqmExpression( null, this ); + // we have form (1) + return new SqmEntityType( + (SqmPath) ctx.entityTypeReference().path().accept( this ), + creationContext.getNodeBuilder() + ); } throw new ParsingException( "Could not interpret grammar context as 'entity type' expression : " + ctx.getText() ); @@ -1320,10 +1317,12 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the concat operator" ); } + + //noinspection unchecked return getFunctionTemplate( "concat" ).makeSqmFunctionExpression( - asList( - (SqmExpression) ctx.expression( 0 ).accept( this ), - (SqmExpression) ctx.expression( 1 ).accept( this ) + (List) asList( + ctx.expression( 0 ).accept( this ), + ctx.expression( 1 ).accept( this ) ), resolveExpressableTypeBasic( String.class ), creationContext.getQueryEngine() @@ -1426,12 +1425,14 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre @Override public SqmCaseSimple visitSimpleCaseStatement(HqlParser.SimpleCaseStatementContext ctx) { + //noinspection unchecked final SqmCaseSimple caseExpression = new SqmCaseSimple( (SqmExpression) ctx.expression().accept( this ), creationContext.getNodeBuilder() ); for ( HqlParser.SimpleCaseWhenContext simpleCaseWhen : ctx.simpleCaseWhen() ) { + //noinspection unchecked caseExpression.when( (SqmExpression) simpleCaseWhen.expression( 0 ).accept( this ), (SqmExpression) simpleCaseWhen.expression( 1 ).accept( this ) @@ -1439,6 +1440,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre } if ( ctx.caseOtherwise() != null ) { + //noinspection unchecked caseExpression.otherwise( (SqmExpression) ctx.caseOtherwise().expression().accept( this ) ); } @@ -1450,6 +1452,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre final SqmCaseSearched caseExpression = new SqmCaseSearched<>( creationContext.getNodeBuilder()); for ( HqlParser.SearchedCaseWhenContext whenFragment : ctx.searchedCaseWhen() ) { + //noinspection unchecked caseExpression.when( (SqmPredicate) whenFragment.predicate().accept( this ), (SqmExpression) whenFragment.expression().accept( this ) @@ -1457,6 +1460,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre } if ( ctx.caseOtherwise() != null ) { + //noinspection unchecked caseExpression.otherwise( (SqmExpression) ctx.caseOtherwise().expression().accept( this ) ); } @@ -1644,6 +1648,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre private SqmLiteral booleanLiteral(boolean value) { final SqmExpressable expressionType = resolveExpressableTypeBasic( Boolean.class ); + //noinspection unchecked return new SqmLiteral<>( value, expressionType, creationContext.getQueryEngine().getCriteriaBuilder() ); } @@ -1662,7 +1667,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre private SqmLiteral stringLiteral(String text) { return new SqmLiteral<>( text, - creationContext.getDomainModel().getTypeConfiguration().resolveStandardBasicType( StandardBasicTypes.STRING ), + resolveExpressableTypeBasic( String.class ), creationContext.getNodeBuilder() ); } @@ -1783,7 +1788,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre } } - private SqmExpressable resolveExpressableTypeBasic(Class javaType) { + private BasicDomainType resolveExpressableTypeBasic(Class javaType) { //noinspection unchecked return creationContext.getDomainModel().getTypeConfiguration().standardBasicTypeForJavaType( javaType ); } @@ -1975,7 +1980,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre return getFunctionTemplate( ctx.trigFunctionName().getText() ).makeSqmFunctionExpression( arg, - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Double.class ), + resolveExpressableTypeBasic( Double.class ), creationContext.getQueryEngine() ); } @@ -2049,56 +2054,56 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre if (ctx.DAY()!=null) { return new SqmExtractUnit<>( "day", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.MONTH()!=null) { return new SqmExtractUnit<>( "month", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.YEAR()!=null) { return new SqmExtractUnit<>( "year", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.HOUR()!=null) { return new SqmExtractUnit<>( "hour", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.MINUTE()!=null) { return new SqmExtractUnit<>( "minute", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.SECOND()!=null) { return new SqmExtractUnit<>( "second", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Float.class ), + resolveExpressableTypeBasic( Float.class ), nodeBuilder ); } if (ctx.WEEK()!=null) { return new SqmExtractUnit<>( "week", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.QUARTER()!=null) { return new SqmExtractUnit<>( "quarter", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } @@ -2113,7 +2118,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre //TODO: need to go back to the dialect, it's called "microseconds" on some return new SqmExtractUnit<>( "microsecond", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } @@ -2121,7 +2126,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre //TODO: need to go back to the dialect, it's called "milliseconds" on some return new SqmExtractUnit<>( "millisecond", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } @@ -2134,14 +2139,14 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre if (ctx.TIMEZONE_HOUR()!=null) { return new SqmExtractUnit<>( "timezone_hour", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } if (ctx.TIMEZONE_MINUTE()!=null) { return new SqmExtractUnit<>( "timezone_minute", - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } @@ -2205,48 +2210,48 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implements SqmCre switch (text.toLowerCase()) { case "string": { return new SqmCastTarget<>( - (AllowableFunctionReturnType) resolveExpressableTypeBasic( String.class ), + resolveExpressableTypeBasic( String.class ), nodeBuilder ); } case "integer": { return new SqmCastTarget<>( - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Integer.class ), + resolveExpressableTypeBasic( Integer.class ), nodeBuilder ); } case "long": { return new SqmCastTarget<>( - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Long.class ), nodeBuilder + resolveExpressableTypeBasic( Long.class ), nodeBuilder ); } case "float": { return new SqmCastTarget<>( - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Float.class ), + resolveExpressableTypeBasic( Float.class ), nodeBuilder ); } case "double": { return new SqmCastTarget<>( - (AllowableFunctionReturnType) resolveExpressableTypeBasic( Double.class ), + resolveExpressableTypeBasic( Double.class ), nodeBuilder ); } case "time": { return new SqmCastTarget<>( - (AllowableFunctionReturnType