Search in sources :

Example 6 with SelectClause

use of org.hibernate.sql.ast.tree.select.SelectClause in project hibernate-orm by hibernate.

the class SmokeTests method testConvertedHqlInterpretation.

@Test
public void testConvertedHqlInterpretation(SessionFactoryScope scope) {
    scope.inTransaction(session -> {
        final JdbcTypeRegistry jdbcTypeRegistry = session.getFactory().getTypeConfiguration().getJdbcTypeRegistry();
        final QueryImplementor<Gender> query = session.createQuery("select e.gender from SimpleEntity e", Gender.class);
        final SqmQueryImplementor<Gender> hqlQuery = (SqmQueryImplementor<Gender>) query;
        final SqmSelectStatement<Gender> sqmStatement = (SqmSelectStatement<Gender>) hqlQuery.getSqmStatement();
        final StandardSqmTranslator<SelectStatement> sqmConverter = new StandardSqmTranslator<>(sqmStatement, hqlQuery.getQueryOptions(), ((QuerySqmImpl<?>) hqlQuery).getDomainParameterXref(), query.getParameterBindings(), session.getLoadQueryInfluencers(), scope.getSessionFactory(), true);
        final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
        final SelectStatement sqlAst = sqmInterpretation.getSqlAst();
        final FromClause fromClause = sqlAst.getQuerySpec().getFromClause();
        assertThat(fromClause.getRoots().size(), is(1));
        final TableGroup rootTableGroup = fromClause.getRoots().get(0);
        assertThat(rootTableGroup.getPrimaryTableReference(), notNullValue());
        assertThat(rootTableGroup.getPrimaryTableReference().getTableId(), is("mapping_simple_entity"));
        assertThat(rootTableGroup.getTableReferenceJoins().size(), is(0));
        assertThat(rootTableGroup.getTableGroupJoins().isEmpty(), is(true));
        // `s` is the "alias stem" for `SimpleEntity` and as it is the first entity with that stem in
        // the query the base becomes `s1`.  The primary table reference is always suffixed as `_0`
        assertThat(rootTableGroup.getPrimaryTableReference().getIdentificationVariable(), is("s1_0"));
        final SelectClause selectClause = sqlAst.getQuerySpec().getSelectClause();
        assertThat(selectClause.getSqlSelections().size(), is(1));
        final SqlSelection sqlSelection = selectClause.getSqlSelections().get(0);
        assertThat(sqlSelection.getJdbcResultSetIndex(), is(1));
        assertThat(sqlSelection.getValuesArrayPosition(), is(0));
        assertThat(sqlSelection.getJdbcValueExtractor(), notNullValue());
        assertThat(sqlSelection, instanceOf(SqlSelectionImpl.class));
        final Expression selectedExpression = sqlSelection.getExpression();
        assertThat(selectedExpression, instanceOf(ColumnReference.class));
        final ColumnReference columnReference = (ColumnReference) selectedExpression;
        assertThat(columnReference.renderSqlFragment(scope.getSessionFactory()), is("s1_0.gender"));
        final JdbcMappingContainer selectedExpressible = selectedExpression.getExpressionType();
        assertThat(selectedExpressible, instanceOf(BasicTypeImpl.class));
        final BasicTypeImpl<?> basicType = (BasicTypeImpl<?>) selectedExpressible;
        assertThat(basicType.getJavaTypeDescriptor().getJavaTypeClass(), AssignableMatcher.assignableTo(Integer.class));
        assertThat(basicType.getJdbcType(), is(jdbcTypeRegistry.getDescriptor(Types.TINYINT)));
        assertThat(sqlAst.getDomainResultDescriptors().size(), is(1));
        final DomainResult<?> domainResult = sqlAst.getDomainResultDescriptors().get(0);
        assertThat(domainResult, instanceOf(BasicResult.class));
        final BasicResult<?> scalarDomainResult = (BasicResult<?>) domainResult;
        assertThat(scalarDomainResult.getAssembler(), instanceOf(BasicResultAssembler.class));
        final BasicResultAssembler<?> assembler = (BasicResultAssembler<?>) scalarDomainResult.getAssembler();
        assertThat(assembler.getValueConverter(), notNullValue());
        assertThat(assembler.getValueConverter(), instanceOf(OrdinalEnumValueConverter.class));
        final NavigablePath expectedSelectedPath = new NavigablePath(SimpleEntity.class.getName(), "e").append("gender");
        assertThat(domainResult.getNavigablePath(), equalTo(expectedSelectedPath));
        assertThat(domainResult, instanceOf(BasicResult.class));
        // ScalarDomainResultImpl creates and caches the assembler at its creation.
        // this just gets access to that cached one
        final DomainResultAssembler<?> resultAssembler = domainResult.createResultAssembler(null, null);
        assertThat(resultAssembler, instanceOf(BasicResultAssembler.class));
        final BasicValueConverter<?, ?> valueConverter = ((BasicResultAssembler<?>) resultAssembler).getValueConverter();
        assertThat(valueConverter, notNullValue());
        assertThat(valueConverter, instanceOf(OrdinalEnumValueConverter.class));
        final JdbcSelect jdbcSelectOperation = new StandardSqlAstTranslator<JdbcSelect>(session.getSessionFactory(), sqlAst).translate(null, QueryOptions.NONE);
        assertThat(jdbcSelectOperation.getSql(), is("select s1_0.gender from mapping_simple_entity s1_0"));
    });
}
Also used : SelectClause(org.hibernate.sql.ast.tree.select.SelectClause) NavigablePath(org.hibernate.query.spi.NavigablePath) BasicTypeImpl(org.hibernate.type.internal.BasicTypeImpl) Gender(org.hibernate.orm.test.mapping.SmokeTests.Gender) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) JdbcMappingContainer(org.hibernate.metamodel.mapping.JdbcMappingContainer) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) BasicResult(org.hibernate.sql.results.graph.basic.BasicResult) OrdinalEnumValueConverter(org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) JdbcSelect(org.hibernate.sql.exec.spi.JdbcSelect) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) BasicResultAssembler(org.hibernate.sql.results.graph.basic.BasicResultAssembler) FromClause(org.hibernate.sql.ast.tree.from.FromClause) Expression(org.hibernate.sql.ast.tree.expression.Expression) SqlSelectionImpl(org.hibernate.sql.results.internal.SqlSelectionImpl) StandardSqmTranslator(org.hibernate.query.sqm.sql.internal.StandardSqmTranslator) JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference) Test(org.junit.jupiter.api.Test)

Example 7 with SelectClause

use of org.hibernate.sql.ast.tree.select.SelectClause in project hibernate-orm by hibernate.

the class SmokeTests method testSimpleHqlInterpretation.

@Test
public void testSimpleHqlInterpretation(SessionFactoryScope scope) {
    scope.inTransaction(session -> {
        final QueryImplementor<String> query = session.createQuery("select e.name from SimpleEntity e", String.class);
        final SqmQueryImplementor<String> hqlQuery = (SqmQueryImplementor<String>) query;
        final SqmSelectStatement<String> sqmStatement = (SqmSelectStatement<String>) hqlQuery.getSqmStatement();
        final StandardSqmTranslator<SelectStatement> sqmConverter = new StandardSqmTranslator<>(sqmStatement, hqlQuery.getQueryOptions(), ((QuerySqmImpl<?>) hqlQuery).getDomainParameterXref(), query.getParameterBindings(), session.getLoadQueryInfluencers(), scope.getSessionFactory(), true);
        final SqmTranslation<SelectStatement> sqmInterpretation = sqmConverter.translate();
        final SelectStatement sqlAst = sqmInterpretation.getSqlAst();
        final FromClause fromClause = sqlAst.getQuerySpec().getFromClause();
        assertThat(fromClause.getRoots().size(), is(1));
        final TableGroup rootTableGroup = fromClause.getRoots().get(0);
        assertThat(rootTableGroup.getPrimaryTableReference(), notNullValue());
        assertThat(rootTableGroup.getPrimaryTableReference().getTableId(), is("mapping_simple_entity"));
        assertThat(rootTableGroup.getTableReferenceJoins().size(), is(0));
        assertThat(rootTableGroup.getTableGroupJoins().isEmpty(), is(true));
        // `s` is the "alias stem" for `SimpleEntity` and as it is the first entity with that stem in
        // the query the base becomes `s1`.  The primary table reference is always suffixed as `_0`
        assertThat(rootTableGroup.getPrimaryTableReference().getIdentificationVariable(), is("s1_0"));
        final SelectClause selectClause = sqlAst.getQuerySpec().getSelectClause();
        assertThat(selectClause.getSqlSelections().size(), is(1));
        final SqlSelection sqlSelection = selectClause.getSqlSelections().get(0);
        assertThat(sqlSelection.getJdbcResultSetIndex(), is(1));
        assertThat(sqlSelection.getValuesArrayPosition(), is(0));
        assertThat(sqlSelection.getJdbcValueExtractor(), notNullValue());
        final JdbcSelect jdbcSelectOperation = new StandardSqlAstTranslator<JdbcSelect>(session.getSessionFactory(), sqlAst).translate(null, QueryOptions.NONE);
        assertThat(jdbcSelectOperation.getSql(), is("select s1_0.name from mapping_simple_entity s1_0"));
    });
}
Also used : SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectClause(org.hibernate.sql.ast.tree.select.SelectClause) JdbcSelect(org.hibernate.sql.exec.spi.JdbcSelect) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) FromClause(org.hibernate.sql.ast.tree.from.FromClause) StandardSqmTranslator(org.hibernate.query.sqm.sql.internal.StandardSqmTranslator) Test(org.junit.jupiter.api.Test)

Example 8 with SelectClause

use of org.hibernate.sql.ast.tree.select.SelectClause in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method visitQuerySpec.

@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
    final boolean topLevel = getProcessingStateStack().isEmpty();
    final QuerySpec sqlQuerySpec = new QuerySpec(topLevel, sqmQuerySpec.getFromClause().getNumberOfRoots());
    final SqmSelectClause selectClause = sqmQuerySpec.getSelectClause();
    final Predicate originalAdditionalRestrictions = additionalRestrictions;
    additionalRestrictions = null;
    final boolean trackAliasedNodePositions;
    if (trackSelectionsForGroup) {
        trackAliasedNodePositions = true;
    } else if (sqmQuerySpec.getOrderByClause() != null && sqmQuerySpec.getOrderByClause().hasPositionalSortItem()) {
        trackAliasedNodePositions = true;
    } else if (sqmQuerySpec.hasPositionalGroupItem()) {
        trackAliasedNodePositions = true;
    } else {
        // Since JPA Criteria queries can use the same expression object in order or group by items,
        // we need to track the positions to be able to replace the expression in the items with alias references
        // Also see #resolveGroupOrOrderByExpression for more details
        trackAliasedNodePositions = statement.getQuerySource() == SqmQuerySource.CRITERIA && (sqmQuerySpec.getOrderByClause() != null || !sqmQuerySpec.getGroupByClauseExpressions().isEmpty());
    }
    final SqlAstProcessingState processingState;
    if (trackAliasedNodePositions) {
        processingState = new SqlAstQueryPartProcessingStateImpl(sqlQuerySpec, getCurrentProcessingState(), this, r -> new SqmAliasedNodePositionTracker(r, selectClause.getSelections()), currentClauseStack::getCurrent, deduplicateSelectionItems);
    } else {
        processingState = new SqlAstQueryPartProcessingStateImpl(sqlQuerySpec, getCurrentProcessingState(), this, currentClauseStack::getCurrent, deduplicateSelectionItems);
    }
    final SqmQueryPart<?> sqmQueryPart = currentSqmQueryPart;
    final boolean originalDeduplicateSelectionItems = deduplicateSelectionItems;
    currentSqmQueryPart = sqmQuerySpec;
    // In sub-queries, we can never deduplicate the selection items as that might change semantics
    deduplicateSelectionItems = false;
    pushProcessingState(processingState);
    queryTransformers.push(new ArrayList<>());
    try {
        // we want to visit the from-clause first
        visitFromClause(sqmQuerySpec.getFromClause());
        visitSelectClause(selectClause);
        final SqmWhereClause whereClause = sqmQuerySpec.getWhereClause();
        if (whereClause != null) {
            sqlQuerySpec.applyPredicate(visitWhereClause(whereClause.getPredicate()));
        }
        sqlQuerySpec.setGroupByClauseExpressions(visitGroupByClause(sqmQuerySpec.getGroupByClauseExpressions()));
        if (sqmQuerySpec.getHavingClausePredicate() != null) {
            sqlQuerySpec.setHavingClauseRestrictions(visitHavingClause(sqmQuerySpec.getHavingClausePredicate()));
        }
        visitOrderByOffsetAndFetch(sqmQuerySpec, sqlQuerySpec);
        if (topLevel && statement instanceof SqmSelectStatement<?>) {
            if (orderByFragments != null) {
                orderByFragments.forEach(entry -> entry.getKey().apply(sqlQuerySpec, entry.getValue(), this));
                orderByFragments = null;
            }
            applyCollectionFilterPredicates(sqlQuerySpec);
        }
        QuerySpec finalQuerySpec = sqlQuerySpec;
        for (QueryTransformer transformer : queryTransformers.getCurrent()) {
            finalQuerySpec = transformer.transform(cteContainer, finalQuerySpec, this);
        }
        return finalQuerySpec;
    } finally {
        if (additionalRestrictions != null) {
            sqlQuerySpec.applyPredicate(additionalRestrictions);
        }
        additionalRestrictions = originalAdditionalRestrictions;
        popProcessingStateStack();
        queryTransformers.pop();
        currentSqmQueryPart = sqmQueryPart;
        deduplicateSelectionItems = originalDeduplicateSelectionItems;
    }
}
Also used : VirtualTableGroup(org.hibernate.sql.ast.tree.from.VirtualTableGroup) SqmToDuration(org.hibernate.query.sqm.tree.expression.SqmToDuration) Statement(org.hibernate.sql.ast.tree.Statement) Format(org.hibernate.sql.ast.tree.expression.Format) SqlExpressible(org.hibernate.metamodel.mapping.SqlExpressible) SqmFieldLiteral(org.hibernate.query.sqm.tree.expression.SqmFieldLiteral) BasicType(org.hibernate.type.BasicType) MultipleBagFetchException(org.hibernate.loader.MultipleBagFetchException) BaseSemanticQueryWalker(org.hibernate.query.sqm.spi.BaseSemanticQueryWalker) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) EntityCollectionPart(org.hibernate.metamodel.mapping.internal.EntityCollectionPart) UNARY_MINUS(org.hibernate.query.sqm.UnaryArithmeticOperator.UNARY_MINUS) SqlTypes(org.hibernate.type.SqlTypes) JdbcMappingContainer(org.hibernate.metamodel.mapping.JdbcMappingContainer) SelfInterpretingSqmPath(org.hibernate.query.sqm.sql.internal.SelfInterpretingSqmPath) PostInsertIdentifierGenerator(org.hibernate.id.PostInsertIdentifierGenerator) Map(java.util.Map) FetchProfile(org.hibernate.engine.profile.FetchProfile) BigInteger(java.math.BigInteger) EntityVersionMapping(org.hibernate.metamodel.mapping.EntityVersionMapping) PluralValuedSimplePathInterpretation(org.hibernate.query.sqm.sql.internal.PluralValuedSimplePathInterpretation) SqmSearchClauseSpecification(org.hibernate.query.sqm.tree.cte.SqmSearchClauseSpecification) SqmCorrelatedRootJoin(org.hibernate.query.sqm.tree.domain.SqmCorrelatedRootJoin) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) IdentifierGenerator(org.hibernate.id.IdentifierGenerator) InSubQueryPredicate(org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate) JdbcType(org.hibernate.type.descriptor.jdbc.JdbcType) InferredBasicValueResolver(org.hibernate.boot.model.process.internal.InferredBasicValueResolver) SqmSummarization(org.hibernate.query.sqm.tree.expression.SqmSummarization) FetchClauseType(org.hibernate.query.sqm.FetchClauseType) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) Optimizer(org.hibernate.id.enhanced.Optimizer) NavigablePath(org.hibernate.query.spi.NavigablePath) AbstractSqlAstTranslator(org.hibernate.sql.ast.spi.AbstractSqlAstTranslator) PreparedStatement(java.sql.PreparedStatement) SqmBooleanExpressionPredicate(org.hibernate.query.sqm.tree.predicate.SqmBooleanExpressionPredicate) SqmQueryPart(org.hibernate.query.sqm.tree.select.SqmQueryPart) SqlAliasBase(org.hibernate.sql.ast.spi.SqlAliasBase) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) StandardStack(org.hibernate.internal.util.collections.StandardStack) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) SqmCteContainer(org.hibernate.query.sqm.tree.cte.SqmCteContainer) SqmJoin(org.hibernate.query.sqm.tree.from.SqmJoin) Overflow(org.hibernate.sql.ast.tree.expression.Overflow) SECOND(org.hibernate.query.sqm.TemporalUnit.SECOND) MappingModelExpressible(org.hibernate.metamodel.mapping.MappingModelExpressible) SqmPath(org.hibernate.query.sqm.tree.domain.SqmPath) FetchParent(org.hibernate.sql.results.graph.FetchParent) SqlAliasBaseGenerator(org.hibernate.sql.ast.spi.SqlAliasBaseGenerator) FilterHelper(org.hibernate.internal.FilterHelper) QueryOptions(org.hibernate.query.spi.QueryOptions) SqmParameterInterpretation(org.hibernate.query.sqm.sql.internal.SqmParameterInterpretation) SearchClauseSpecification(org.hibernate.sql.ast.tree.cte.SearchClauseSpecification) JdbcTypeIndicators(org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators) SelfRenderingPredicate(org.hibernate.sql.ast.tree.predicate.SelfRenderingPredicate) SqmBasicValuedSimplePath(org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath) Supplier(java.util.function.Supplier) SemanticException(org.hibernate.query.SemanticException) JdbcParameterBindings(org.hibernate.sql.exec.spi.JdbcParameterBindings) SqmIndexAggregateFunction(org.hibernate.query.sqm.tree.domain.SqmIndexAggregateFunction) LinkedHashMap(java.util.LinkedHashMap) CteTable(org.hibernate.sql.ast.tree.cte.CteTable) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) BasicSqmPathSource(org.hibernate.metamodel.model.domain.internal.BasicSqmPathSource) SqmTuple(org.hibernate.query.sqm.tree.expression.SqmTuple) SqmQuerySpec(org.hibernate.query.sqm.tree.select.SqmQuerySpec) BasicDomainType(org.hibernate.metamodel.model.domain.BasicDomainType) SqmSetClause(org.hibernate.query.sqm.tree.update.SqmSetClause) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqmDynamicInstantiationTarget(org.hibernate.query.sqm.tree.select.SqmDynamicInstantiationTarget) ToOneAttributeMapping(org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping) NegatedPredicate(org.hibernate.sql.ast.tree.predicate.NegatedPredicate) TimestampaddFunction(org.hibernate.dialect.function.TimestampaddFunction) JpaCriteriaParameter(org.hibernate.query.sqm.tree.expression.JpaCriteriaParameter) SqmVisitableNode(org.hibernate.query.sqm.tree.SqmVisitableNode) BasicJavaType(org.hibernate.type.descriptor.java.BasicJavaType) DeleteStatement(org.hibernate.sql.ast.tree.delete.DeleteStatement) ModelPartContainer(org.hibernate.metamodel.mapping.ModelPartContainer) QueryParameterBindings(org.hibernate.query.spi.QueryParameterBindings) SqmOver(org.hibernate.query.sqm.tree.expression.SqmOver) LikePredicate(org.hibernate.sql.ast.tree.predicate.LikePredicate) EntityDiscriminatorMapping(org.hibernate.metamodel.mapping.EntityDiscriminatorMapping) QueryLiteral(org.hibernate.sql.ast.tree.expression.QueryLiteral) SqlTypedMapping(org.hibernate.metamodel.mapping.SqlTypedMapping) Fetch(org.hibernate.sql.results.graph.Fetch) EntityGraphTraversalState(org.hibernate.sql.results.graph.EntityGraphTraversalState) FromClauseAccess(org.hibernate.sql.ast.spi.FromClauseAccess) SUBTRACT(org.hibernate.query.sqm.BinaryArithmeticOperator.SUBTRACT) SqlSelectionImpl(org.hibernate.sql.results.internal.SqlSelectionImpl) SqmFromClause(org.hibernate.query.sqm.tree.from.SqmFromClause) SqmRoot(org.hibernate.query.sqm.tree.from.SqmRoot) DomainParameterXref(org.hibernate.query.sqm.internal.DomainParameterXref) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) DynamicInstantiationNature(org.hibernate.query.sqm.DynamicInstantiationNature) JdbcParametersImpl(org.hibernate.sql.exec.internal.JdbcParametersImpl) UserVersionType(org.hibernate.usertype.UserVersionType) Bindable(org.hibernate.metamodel.mapping.Bindable) EntityPersister(org.hibernate.persister.entity.EntityPersister) SqlAstProcessingStateImpl(org.hibernate.query.sqm.sql.internal.SqlAstProcessingStateImpl) PredicateCollector(org.hibernate.sql.ast.tree.predicate.PredicateCollector) ADD(org.hibernate.query.sqm.BinaryArithmeticOperator.ADD) TimestampdiffFunction(org.hibernate.dialect.function.TimestampdiffFunction) CompositeSqmPathSource(org.hibernate.metamodel.model.domain.internal.CompositeSqmPathSource) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) NotYetImplementedFor6Exception(org.hibernate.NotYetImplementedFor6Exception) SqmModifiedSubQueryExpression(org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression) SqmSortSpecification(org.hibernate.query.sqm.tree.select.SqmSortSpecification) SqmCaseSearched(org.hibernate.query.sqm.tree.expression.SqmCaseSearched) SqmIndexedCollectionAccessPath(org.hibernate.query.sqm.tree.domain.SqmIndexedCollectionAccessPath) SqmLiteralNull(org.hibernate.query.sqm.tree.expression.SqmLiteralNull) Locale(java.util.Locale) ConvertibleModelPart(org.hibernate.metamodel.mapping.ConvertibleModelPart) SqmMapEntryReference(org.hibernate.query.sqm.tree.domain.SqmMapEntryReference) BetweenPredicate(org.hibernate.sql.ast.tree.predicate.BetweenPredicate) AbstractJdbcParameter(org.hibernate.sql.exec.internal.AbstractJdbcParameter) JdbcParameterImpl(org.hibernate.sql.exec.internal.JdbcParameterImpl) SqmOverflow(org.hibernate.query.sqm.tree.expression.SqmOverflow) ComparisonOperator(org.hibernate.query.sqm.ComparisonOperator) SqmInsertSelectStatement(org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement) CollectionPart(org.hibernate.metamodel.mapping.CollectionPart) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) Assignable(org.hibernate.sql.ast.tree.update.Assignable) SqmPredicate(org.hibernate.query.sqm.tree.predicate.SqmPredicate) Any(org.hibernate.sql.ast.tree.expression.Any) Assignment(org.hibernate.sql.ast.tree.update.Assignment) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelfRenderingFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression) Collection(java.util.Collection) SingleTableEntityPersister(org.hibernate.persister.entity.SingleTableEntityPersister) BasicValuedMapping(org.hibernate.metamodel.mapping.BasicValuedMapping) OrderByFragment(org.hibernate.metamodel.mapping.ordering.OrderByFragment) SqmBinaryArithmetic(org.hibernate.query.sqm.tree.expression.SqmBinaryArithmetic) SqmJpaCriteriaParameterWrapper(org.hibernate.query.sqm.tree.expression.SqmJpaCriteriaParameterWrapper) SqmAnyValuedSimplePath(org.hibernate.query.sqm.tree.domain.SqmAnyValuedSimplePath) UpdateStatement(org.hibernate.sql.ast.tree.update.UpdateStatement) SqmNegatedPredicate(org.hibernate.query.sqm.tree.predicate.SqmNegatedPredicate) QueryTransformer(org.hibernate.sql.ast.tree.expression.QueryTransformer) SqlAstProcessingState(org.hibernate.sql.ast.spi.SqlAstProcessingState) CorrelatedPluralTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedPluralTableGroup) EntityTypeLiteral(org.hibernate.sql.ast.tree.expression.EntityTypeLiteral) QueryParameterImplementor(org.hibernate.query.spi.QueryParameterImplementor) SqmExtractUnit(org.hibernate.query.sqm.tree.expression.SqmExtractUnit) SqmCrossJoin(org.hibernate.query.sqm.tree.from.SqmCrossJoin) ExistsPredicate(org.hibernate.sql.ast.tree.predicate.ExistsPredicate) SqmFrom(org.hibernate.query.sqm.tree.from.SqmFrom) NullnessHelper.coalesceSuppliedValues(org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues) SqmPositionalParameter(org.hibernate.query.sqm.tree.expression.SqmPositionalParameter) DomainResultCreationState(org.hibernate.sql.results.graph.DomainResultCreationState) SqmAliasedNode(org.hibernate.query.sqm.tree.select.SqmAliasedNode) SqmDynamicInstantiationArgument(org.hibernate.query.sqm.tree.select.SqmDynamicInstantiationArgument) SqmSelectableNode(org.hibernate.query.sqm.tree.select.SqmSelectableNode) JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) NATIVE(org.hibernate.query.sqm.TemporalUnit.NATIVE) Logger(org.jboss.logging.Logger) UnaryOperation(org.hibernate.sql.ast.tree.expression.UnaryOperation) OptimizableGenerator(org.hibernate.id.OptimizableGenerator) SqmParameterizedEntityType(org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType) Function(java.util.function.Function) SortOrder(org.hibernate.query.sqm.SortOrder) Duration(org.hibernate.sql.ast.tree.expression.Duration) SqmEnumLiteral(org.hibernate.query.sqm.tree.expression.SqmEnumLiteral) ExtractUnit(org.hibernate.sql.ast.tree.expression.ExtractUnit) TableReference(org.hibernate.sql.ast.tree.from.TableReference) HashSet(java.util.HashSet) ModelPart(org.hibernate.metamodel.mapping.ModelPart) SqmTreatedRoot(org.hibernate.query.sqm.tree.domain.SqmTreatedRoot) SqmEvery(org.hibernate.query.sqm.tree.expression.SqmEvery) SqmNamedParameter(org.hibernate.query.sqm.tree.expression.SqmNamedParameter) SqlTreeCreationException(org.hibernate.sql.ast.SqlTreeCreationException) BinaryArithmeticOperator(org.hibernate.query.sqm.BinaryArithmeticOperator) SqmAndPredicate(org.hibernate.query.sqm.tree.predicate.SqmAndPredicate) SqlAliasBaseManager(org.hibernate.sql.ast.spi.SqlAliasBaseManager) SqmByUnit(org.hibernate.query.sqm.tree.expression.SqmByUnit) SqlAstQueryPartProcessingStateImpl(org.hibernate.query.sqm.sql.internal.SqlAstQueryPartProcessingStateImpl) CompositeNestedGeneratedValueGenerator(org.hibernate.id.CompositeNestedGeneratedValueGenerator) SqmMemberOfPredicate(org.hibernate.query.sqm.tree.predicate.SqmMemberOfPredicate) Values(org.hibernate.sql.ast.tree.insert.Values) DomainResultProducer(org.hibernate.query.sqm.sql.internal.DomainResultProducer) SelfRenderingAggregateFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingAggregateFunctionSqlAstExpression) AppliedGraph(org.hibernate.graph.spi.AppliedGraph) QueryGroup(org.hibernate.sql.ast.tree.select.QueryGroup) DiscriminatedAssociationPathInterpretation(org.hibernate.query.sqm.sql.internal.DiscriminatedAssociationPathInterpretation) SqmUnaryOperation(org.hibernate.query.sqm.tree.expression.SqmUnaryOperation) QueryPartTableReference(org.hibernate.sql.ast.tree.from.QueryPartTableReference) PluralPersistentAttribute(org.hibernate.metamodel.model.domain.PluralPersistentAttribute) UnaryArithmeticOperator(org.hibernate.query.sqm.UnaryArithmeticOperator) Consumer(java.util.function.Consumer) AbstractMap(java.util.AbstractMap) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) JdbcParameter(org.hibernate.sql.ast.tree.expression.JdbcParameter) SqmInsertStatement(org.hibernate.query.sqm.tree.insert.SqmInsertStatement) SelectableMapping(org.hibernate.metamodel.mapping.SelectableMapping) SqlTypedMappingJdbcParameter(org.hibernate.sql.exec.internal.SqlTypedMappingJdbcParameter) SqmPluralPartJoin(org.hibernate.query.sqm.tree.domain.SqmPluralPartJoin) NonAggregatedCompositeSimplePath(org.hibernate.query.sqm.tree.domain.NonAggregatedCompositeSimplePath) BasicValueConverter(org.hibernate.metamodel.model.convert.spi.BasicValueConverter) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) Arrays(java.util.Arrays) SqmExpressible(org.hibernate.query.sqm.SqmExpressible) SqmFormat(org.hibernate.query.sqm.tree.expression.SqmFormat) EPOCH(org.hibernate.query.sqm.TemporalUnit.EPOCH) SqmAttributeJoin(org.hibernate.query.sqm.tree.from.SqmAttributeJoin) SqmCaseSimple(org.hibernate.query.sqm.tree.expression.SqmCaseSimple) SqlAstTreeHelper(org.hibernate.sql.ast.spi.SqlAstTreeHelper) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) SqmLikePredicate(org.hibernate.query.sqm.tree.predicate.SqmLikePredicate) Internal(org.hibernate.Internal) SqmStatement(org.hibernate.query.sqm.tree.SqmStatement) SqmPluralValuedSimplePath(org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath) SqmTreatedPath(org.hibernate.query.sqm.tree.domain.SqmTreatedPath) BigDecimal(java.math.BigDecimal) SqmAliasedNodeRef(org.hibernate.query.sqm.tree.expression.SqmAliasedNodeRef) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) BindableType(org.hibernate.query.BindableType) SqmExistsPredicate(org.hibernate.query.sqm.tree.predicate.SqmExistsPredicate) SqmEmbeddedValuedSimplePath(org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath) EntityValuedPathInterpretation(org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation) PatternRenderer(org.hibernate.query.sqm.produce.function.internal.PatternRenderer) SqmCastTarget(org.hibernate.query.sqm.tree.expression.SqmCastTarget) Fetchable(org.hibernate.sql.results.graph.Fetchable) DAY(org.hibernate.query.sqm.TemporalUnit.DAY) SelfRenderingSqlFragmentExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingSqlFragmentExpression) ConvertedQueryLiteral(org.hibernate.sql.ast.tree.expression.ConvertedQueryLiteral) TypeConfiguration(org.hibernate.type.spi.TypeConfiguration) SqmEntityValuedSimplePath(org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath) Set(java.util.Set) Expression(org.hibernate.sql.ast.tree.expression.Expression) TemporalUnit(org.hibernate.query.sqm.TemporalUnit) SqmCollectionSize(org.hibernate.query.sqm.tree.expression.SqmCollectionSize) EntityIdentifierMapping(org.hibernate.metamodel.mapping.EntityIdentifierMapping) SqmTrimSpecification(org.hibernate.query.sqm.tree.expression.SqmTrimSpecification) SqlAstQueryPartProcessingState(org.hibernate.sql.ast.spi.SqlAstQueryPartProcessingState) SqlTuple(org.hibernate.sql.ast.tree.expression.SqlTuple) JpaPath(org.hibernate.query.criteria.JpaPath) Star(org.hibernate.sql.ast.tree.expression.Star) SqmParameter(org.hibernate.query.sqm.tree.expression.SqmParameter) ValueMapping(org.hibernate.metamodel.mapping.ValueMapping) SqmPathSource(org.hibernate.query.sqm.SqmPathSource) Conversion(org.hibernate.query.sqm.tree.expression.Conversion) InsertStatement(org.hibernate.sql.ast.tree.insert.InsertStatement) SqlTypedMappingImpl(org.hibernate.metamodel.mapping.internal.SqlTypedMappingImpl) SqmJoinType(org.hibernate.query.sqm.tree.SqmJoinType) SqmCollation(org.hibernate.query.sqm.tree.expression.SqmCollation) HibernateException(org.hibernate.HibernateException) QueryException(org.hibernate.QueryException) SqmSelectClause(org.hibernate.query.sqm.tree.select.SqmSelectClause) SqmAny(org.hibernate.query.sqm.tree.expression.SqmAny) JdbcLiteral(org.hibernate.sql.ast.tree.expression.JdbcLiteral) NonAggregatedCompositeValuedPathInterpretation(org.hibernate.query.sqm.sql.internal.NonAggregatedCompositeValuedPathInterpretation) SqmLiteralEntityType(org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType) CteContainer(org.hibernate.sql.ast.tree.cte.CteContainer) Distinct(org.hibernate.sql.ast.tree.expression.Distinct) JavaType(org.hibernate.type.descriptor.java.JavaType) SqmDurationUnit(org.hibernate.query.sqm.tree.expression.SqmDurationUnit) SqmSubQuery(org.hibernate.query.sqm.tree.select.SqmSubQuery) InterpretationException(org.hibernate.query.sqm.InterpretationException) Clause(org.hibernate.sql.ast.Clause) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) EntityDomainType(org.hibernate.metamodel.model.domain.EntityDomainType) SqmOrPredicate(org.hibernate.query.sqm.tree.predicate.SqmOrPredicate) BiConsumer(java.util.function.BiConsumer) QueryParameterBinding(org.hibernate.query.spi.QueryParameterBinding) SqmCorrelation(org.hibernate.query.sqm.tree.domain.SqmCorrelation) SqlAstNode(org.hibernate.sql.ast.tree.SqlAstNode) MULTIPLY(org.hibernate.query.sqm.BinaryArithmeticOperator.MULTIPLY) ReturnableType(org.hibernate.query.ReturnableType) VersionTypeSeedParameterSpecification(org.hibernate.sql.exec.internal.VersionTypeSeedParameterSpecification) FetchTiming(org.hibernate.engine.FetchTiming) BulkInsertionCapableIdentifierGenerator(org.hibernate.id.BulkInsertionCapableIdentifierGenerator) SqmNullnessPredicate(org.hibernate.query.sqm.tree.predicate.SqmNullnessPredicate) DiscriminatorSqmPath(org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPath) SqmElementAggregateFunction(org.hibernate.query.sqm.tree.domain.SqmElementAggregateFunction) SqmQueryGroup(org.hibernate.query.sqm.tree.select.SqmQueryGroup) SqlTreeCreationLogger(org.hibernate.sql.ast.SqlTreeCreationLogger) StandardEntityGraphTraversalStateImpl(org.hibernate.sql.results.internal.StandardEntityGraphTraversalStateImpl) SqmAssignment(org.hibernate.query.sqm.tree.update.SqmAssignment) CollectionClassification(org.hibernate.metamodel.CollectionClassification) SqmWhereClause(org.hibernate.query.sqm.tree.predicate.SqmWhereClause) SqmComparisonPredicate(org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate) SqmGroupedPredicate(org.hibernate.query.sqm.tree.predicate.SqmGroupedPredicate) SqmPathInterpretation(org.hibernate.query.sqm.sql.internal.SqmPathInterpretation) SqmValues(org.hibernate.query.sqm.tree.insert.SqmValues) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) CollectionHelper(org.hibernate.internal.util.collections.CollectionHelper) SqmJpaCompoundSelection(org.hibernate.query.sqm.tree.select.SqmJpaCompoundSelection) ExecutionContext(org.hibernate.sql.exec.spi.ExecutionContext) CastTarget(org.hibernate.sql.ast.tree.expression.CastTarget) SqmCteTable(org.hibernate.query.sqm.tree.cte.SqmCteTable) SqmInsertValuesStatement(org.hibernate.query.sqm.tree.insert.SqmInsertValuesStatement) CteStatement(org.hibernate.sql.ast.tree.cte.CteStatement) Joinable(org.hibernate.persister.entity.Joinable) SqmExpression(org.hibernate.query.sqm.tree.expression.SqmExpression) SqmFunction(org.hibernate.query.sqm.tree.expression.SqmFunction) SqlAstCreationContext(org.hibernate.sql.ast.spi.SqlAstCreationContext) SqmEntityJoin(org.hibernate.query.sqm.tree.from.SqmEntityJoin) SqmInListPredicate(org.hibernate.query.sqm.tree.predicate.SqmInListPredicate) ComparisonPredicate(org.hibernate.sql.ast.tree.predicate.ComparisonPredicate) EntityAssociationMapping(org.hibernate.metamodel.mapping.EntityAssociationMapping) EmbeddableValuedPathInterpretation(org.hibernate.query.sqm.sql.internal.EmbeddableValuedPathInterpretation) Summarization(org.hibernate.sql.ast.tree.expression.Summarization) DynamicInstantiation(org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiation) TypeConfiguration.isDuration(org.hibernate.type.spi.TypeConfiguration.isDuration) SqmUpdateStatement(org.hibernate.query.sqm.tree.update.SqmUpdateStatement) EnumJavaType(org.hibernate.type.descriptor.java.EnumJavaType) SqmMapEntryResult(org.hibernate.query.sqm.sql.internal.SqmMapEntryResult) SqmOrderByClause(org.hibernate.query.sqm.tree.select.SqmOrderByClause) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) TemporalType(jakarta.persistence.TemporalType) TableGroupJoinProducer(org.hibernate.sql.ast.tree.from.TableGroupJoinProducer) SqmDeleteStatement(org.hibernate.query.sqm.tree.delete.SqmDeleteStatement) IdentityHashMap(java.util.IdentityHashMap) NullnessPredicate(org.hibernate.sql.ast.tree.predicate.NullnessPredicate) SqmBetweenPredicate(org.hibernate.query.sqm.tree.predicate.SqmBetweenPredicate) DomainResult(org.hibernate.sql.results.graph.DomainResult) OrdinalEnumValueConverter(org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) GroupedPredicate(org.hibernate.sql.ast.tree.predicate.GroupedPredicate) MappingMetamodel(org.hibernate.metamodel.MappingMetamodel) LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) List(java.util.List) QueryPartTableGroup(org.hibernate.sql.ast.tree.from.QueryPartTableGroup) BooleanExpressionPredicate(org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate) Over(org.hibernate.sql.ast.tree.expression.Over) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) QuerySpec(org.hibernate.sql.ast.tree.select.QuerySpec) DurationUnit(org.hibernate.sql.ast.tree.expression.DurationUnit) BasicValuedModelPart(org.hibernate.metamodel.mapping.BasicValuedModelPart) Collation(org.hibernate.sql.ast.tree.expression.Collation) InListPredicate(org.hibernate.sql.ast.tree.predicate.InListPredicate) BasicEntityIdentifierMapping(org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping) Junction(org.hibernate.sql.ast.tree.predicate.Junction) SelectableMappings(org.hibernate.metamodel.mapping.SelectableMappings) SqmDistinct(org.hibernate.query.sqm.tree.expression.SqmDistinct) SqmInSubQueryPredicate(org.hibernate.query.sqm.tree.predicate.SqmInSubQueryPredicate) QueryLogging(org.hibernate.query.QueryLogging) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference) HashMap(java.util.HashMap) SqmLiteral(org.hibernate.query.sqm.tree.expression.SqmLiteral) SqmEmptinessPredicate(org.hibernate.query.sqm.tree.predicate.SqmEmptinessPredicate) SortSpecification(org.hibernate.sql.ast.tree.select.SortSpecification) AbstractSqmSpecificPluralPartPath(org.hibernate.query.sqm.tree.domain.AbstractSqmSpecificPluralPartPath) CteColumn(org.hibernate.sql.ast.tree.cte.CteColumn) SqmDynamicInstantiation(org.hibernate.query.sqm.tree.select.SqmDynamicInstantiation) JavaObjectType(org.hibernate.type.JavaObjectType) JdbcParameters(org.hibernate.sql.exec.spi.JdbcParameters) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) LockMode(org.hibernate.LockMode) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate) Iterator(java.util.Iterator) EmbeddableMappingType(org.hibernate.metamodel.mapping.EmbeddableMappingType) SqmStar(org.hibernate.query.sqm.tree.expression.SqmStar) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) SqmSelection(org.hibernate.query.sqm.tree.select.SqmSelection) SqmQuerySource(org.hibernate.query.sqm.SqmQuerySource) SqmCteStatement(org.hibernate.query.sqm.tree.cte.SqmCteStatement) SqmTypedNode(org.hibernate.query.sqm.tree.SqmTypedNode) EmbeddedCollectionPart(org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart) AbstractSqmSelfRenderingFunctionDescriptor(org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor) TrimSpecification(org.hibernate.sql.ast.tree.expression.TrimSpecification) SelectClause(org.hibernate.sql.ast.tree.select.SelectClause) Association(org.hibernate.metamodel.mapping.Association) CastType(org.hibernate.query.sqm.CastType) SqmCteTableColumn(org.hibernate.query.sqm.tree.cte.SqmCteTableColumn) Every(org.hibernate.sql.ast.tree.expression.Every) SqmMappingModelHelper(org.hibernate.query.sqm.internal.SqmMappingModelHelper) QueryPart(org.hibernate.sql.ast.tree.select.QueryPart) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) Stack(org.hibernate.internal.util.collections.Stack) AttributeMapping(org.hibernate.metamodel.mapping.AttributeMapping) BasicValuedPathInterpretation(org.hibernate.query.sqm.sql.internal.BasicValuedPathInterpretation) Collections(java.util.Collections) EntityTypeImpl(org.hibernate.metamodel.model.domain.internal.EntityTypeImpl) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) SqmSelectClause(org.hibernate.query.sqm.tree.select.SqmSelectClause) QueryTransformer(org.hibernate.sql.ast.tree.expression.QueryTransformer) InSubQueryPredicate(org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate) SqmBooleanExpressionPredicate(org.hibernate.query.sqm.tree.predicate.SqmBooleanExpressionPredicate) SelfRenderingPredicate(org.hibernate.sql.ast.tree.predicate.SelfRenderingPredicate) NegatedPredicate(org.hibernate.sql.ast.tree.predicate.NegatedPredicate) LikePredicate(org.hibernate.sql.ast.tree.predicate.LikePredicate) BetweenPredicate(org.hibernate.sql.ast.tree.predicate.BetweenPredicate) SqmPredicate(org.hibernate.query.sqm.tree.predicate.SqmPredicate) SqmNegatedPredicate(org.hibernate.query.sqm.tree.predicate.SqmNegatedPredicate) ExistsPredicate(org.hibernate.sql.ast.tree.predicate.ExistsPredicate) SqmAndPredicate(org.hibernate.query.sqm.tree.predicate.SqmAndPredicate) SqmMemberOfPredicate(org.hibernate.query.sqm.tree.predicate.SqmMemberOfPredicate) SqmLikePredicate(org.hibernate.query.sqm.tree.predicate.SqmLikePredicate) SqmExistsPredicate(org.hibernate.query.sqm.tree.predicate.SqmExistsPredicate) SqmOrPredicate(org.hibernate.query.sqm.tree.predicate.SqmOrPredicate) SqmNullnessPredicate(org.hibernate.query.sqm.tree.predicate.SqmNullnessPredicate) SqmComparisonPredicate(org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate) SqmGroupedPredicate(org.hibernate.query.sqm.tree.predicate.SqmGroupedPredicate) SqmInListPredicate(org.hibernate.query.sqm.tree.predicate.SqmInListPredicate) ComparisonPredicate(org.hibernate.sql.ast.tree.predicate.ComparisonPredicate) NullnessPredicate(org.hibernate.sql.ast.tree.predicate.NullnessPredicate) SqmBetweenPredicate(org.hibernate.query.sqm.tree.predicate.SqmBetweenPredicate) GroupedPredicate(org.hibernate.sql.ast.tree.predicate.GroupedPredicate) BooleanExpressionPredicate(org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate) InListPredicate(org.hibernate.sql.ast.tree.predicate.InListPredicate) SqmInSubQueryPredicate(org.hibernate.query.sqm.tree.predicate.SqmInSubQueryPredicate) SqmEmptinessPredicate(org.hibernate.query.sqm.tree.predicate.SqmEmptinessPredicate) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate) SqlAstProcessingState(org.hibernate.sql.ast.spi.SqlAstProcessingState) SqlAstQueryPartProcessingStateImpl(org.hibernate.query.sqm.sql.internal.SqlAstQueryPartProcessingStateImpl) SqmWhereClause(org.hibernate.query.sqm.tree.predicate.SqmWhereClause) SqmQuerySpec(org.hibernate.query.sqm.tree.select.SqmQuerySpec) QuerySpec(org.hibernate.sql.ast.tree.select.QuerySpec)

Example 9 with SelectClause

use of org.hibernate.sql.ast.tree.select.SelectClause in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method visitSelectClause.

@Override
public SelectClause visitSelectClause(SqmSelectClause selectClause) {
    currentClauseStack.push(Clause.SELECT);
    try {
        final SelectClause sqlSelectClause = currentQuerySpec().getSelectClause();
        if (selectClause == null) {
            final SqmFrom<?, ?> implicitSelection = determineImplicitSelection((SqmQuerySpec<?>) currentSqmQueryPart);
            visitSelection(new SqmSelection<>(implicitSelection, implicitSelection.nodeBuilder()));
        } else {
            super.visitSelectClause(selectClause);
            sqlSelectClause.makeDistinct(selectClause.isDistinct());
        }
        return sqlSelectClause;
    } finally {
        currentClauseStack.pop();
    }
}
Also used : SqmSelectClause(org.hibernate.query.sqm.tree.select.SqmSelectClause) SelectClause(org.hibernate.sql.ast.tree.select.SelectClause)

Example 10 with SelectClause

use of org.hibernate.sql.ast.tree.select.SelectClause in project hibernate-orm by hibernate.

the class AbstractSqlAstTranslator method renderQueryGroup.

protected void renderQueryGroup(QueryGroup queryGroup, boolean renderOrderByAndOffsetFetchClause) {
    final QueryPart queryPartForRowNumbering = this.queryPartForRowNumbering;
    final int queryPartForRowNumberingClauseDepth = this.queryPartForRowNumberingClauseDepth;
    final boolean needsSelectAliases = this.needsSelectAliases;
    try {
        String queryGroupAlias = null;
        // See the field documentation of queryPartForRowNumbering etc. for an explanation about this
        final QueryPart currentQueryPart = queryPartStack.getCurrent();
        if (currentQueryPart != null && queryPartForRowNumberingClauseDepth != clauseStack.depth()) {
            this.queryPartForRowNumbering = null;
            this.queryPartForRowNumberingClauseDepth = -1;
            this.needsSelectAliases = false;
        }
        final boolean needsParenthesis = !queryGroup.isRoot();
        if (needsParenthesis) {
            appendSql(OPEN_PARENTHESIS);
        }
        // order by and offset fetch clause, so we must do row counting on the query group level
        if (queryPartForRowNumbering == queryGroup || additionalWherePredicate != null && !additionalWherePredicate.isEmpty()) {
            this.needsSelectAliases = true;
            queryGroupAlias = "grp_" + queryGroupAliasCounter + '_';
            queryGroupAliasCounter++;
            appendSql("select ");
            appendSql(queryGroupAlias);
            appendSql(".* ");
            final SelectClause firstSelectClause = queryGroup.getFirstQuerySpec().getSelectClause();
            final List<SqlSelection> sqlSelections = firstSelectClause.getSqlSelections();
            final int sqlSelectionsSize = sqlSelections.size();
            // We need this synthetic select clause to properly render the ORDER BY within the OVER clause
            // of the row numbering functions
            final SelectClause syntheticSelectClause = new SelectClause(sqlSelectionsSize);
            for (int i = 0; i < sqlSelectionsSize; i++) {
                syntheticSelectClause.addSqlSelection(new SqlSelectionImpl(i + 1, i, new ColumnReference(queryGroupAlias, "c" + i, false, null, null, getIntegerType(), null)));
            }
            renderRowNumberingSelectItems(syntheticSelectClause, queryPartForRowNumbering);
            appendSql(" from (");
        }
        queryPartStack.push(queryGroup);
        final List<QueryPart> queryParts = queryGroup.getQueryParts();
        final String setOperatorString = ' ' + queryGroup.getSetOperator().sqlString() + ' ';
        String separator = "";
        for (int i = 0; i < queryParts.size(); i++) {
            appendSql(separator);
            queryParts.get(i).accept(this);
            separator = setOperatorString;
        }
        if (renderOrderByAndOffsetFetchClause) {
            visitOrderBy(queryGroup.getSortSpecifications());
            visitOffsetFetchClause(queryGroup);
        }
        if (queryGroupAlias != null) {
            appendSql(") ");
            appendSql(queryGroupAlias);
            if (additionalWherePredicate != null && !additionalWherePredicate.isEmpty()) {
                visitWhereClause(additionalWherePredicate);
            }
        }
        if (needsParenthesis) {
            appendSql(CLOSE_PARENTHESIS);
        }
    } finally {
        queryPartStack.pop();
        this.queryPartForRowNumbering = queryPartForRowNumbering;
        this.queryPartForRowNumberingClauseDepth = queryPartForRowNumberingClauseDepth;
        this.needsSelectAliases = needsSelectAliases;
    }
}
Also used : SelectClause(org.hibernate.sql.ast.tree.select.SelectClause) QueryPart(org.hibernate.sql.ast.tree.select.QueryPart) SqlSelectionImpl(org.hibernate.sql.results.internal.SqlSelectionImpl) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference)

Aggregations

SelectClause (org.hibernate.sql.ast.tree.select.SelectClause)10 SqlSelection (org.hibernate.sql.ast.spi.SqlSelection)7 ColumnReference (org.hibernate.sql.ast.tree.expression.ColumnReference)6 QuerySpec (org.hibernate.sql.ast.tree.select.QuerySpec)6 SqlSelectionImpl (org.hibernate.sql.results.internal.SqlSelectionImpl)6 NavigablePath (org.hibernate.query.spi.NavigablePath)5 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)5 SelectStatement (org.hibernate.sql.ast.tree.select.SelectStatement)5 Expression (org.hibernate.sql.ast.tree.expression.Expression)4 ArrayList (java.util.ArrayList)3 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)3 SqmSelectStatement (org.hibernate.query.sqm.tree.select.SqmSelectStatement)3 SqlAliasBaseManager (org.hibernate.sql.ast.spi.SqlAliasBaseManager)3 SqlTuple (org.hibernate.sql.ast.tree.expression.SqlTuple)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 FetchTiming (org.hibernate.engine.FetchTiming)2 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)2