Search in sources :

Example 6 with PluralTableGroup

use of org.hibernate.sql.ast.tree.from.PluralTableGroup in project hibernate-orm by hibernate.

the class BasicValuedCollectionPart method resolveSqlSelection.

private SqlSelection resolveSqlSelection(NavigablePath navigablePath, TableGroup tableGroup, boolean allowFkOptimization, DomainResultCreationState creationState) {
    final SqlExpressionResolver exprResolver = creationState.getSqlAstCreationState().getSqlExpressionResolver();
    final TableGroup targetTableGroup;
    // into the element table group though because the element table group navigable path is not the parent of this navigable path
    if (nature == Nature.INDEX && collectionDescriptor.getAttributeMapping().getIndexMetadata().getIndexPropertyName() != null) {
        targetTableGroup = ((PluralTableGroup) tableGroup).getElementTableGroup();
    } else {
        targetTableGroup = tableGroup;
    }
    final TableReference tableReference = targetTableGroup.resolveTableReference(navigablePath, getContainingTableExpression(), allowFkOptimization);
    return exprResolver.resolveSqlSelection(exprResolver.resolveSqlExpression(SqlExpressionResolver.createColumnReferenceKey(tableReference, selectableMapping.getSelectionExpression()), sqlAstProcessingState -> new ColumnReference(tableReference, selectableMapping, creationState.getSqlAstCreationState().getCreationContext().getSessionFactory())), getJavaType(), creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration());
}
Also used : BasicValuedModelPart(org.hibernate.metamodel.mapping.BasicValuedModelPart) DomainResultCreationState(org.hibernate.sql.results.graph.DomainResultCreationState) ResultsLogger(org.hibernate.sql.results.ResultsLogger) JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference) JavaType(org.hibernate.type.descriptor.java.JavaType) Clause(org.hibernate.sql.ast.Clause) BasicFetch(org.hibernate.sql.results.graph.basic.BasicFetch) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) MappingType(org.hibernate.metamodel.mapping.MappingType) TableReference(org.hibernate.sql.ast.tree.from.TableReference) ConvertibleModelPart(org.hibernate.metamodel.mapping.ConvertibleModelPart) FetchOptions(org.hibernate.sql.results.graph.FetchOptions) BiConsumer(java.util.function.BiConsumer) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) CollectionPart(org.hibernate.metamodel.mapping.CollectionPart) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) FetchTiming(org.hibernate.engine.FetchTiming) NavigablePath(org.hibernate.query.spi.NavigablePath) DomainResult(org.hibernate.sql.results.graph.DomainResult) Fetch(org.hibernate.sql.results.graph.Fetch) BasicResult(org.hibernate.sql.results.graph.basic.BasicResult) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) FetchStyle(org.hibernate.engine.FetchStyle) List(java.util.List) SelectableMapping(org.hibernate.metamodel.mapping.SelectableMapping) BasicValueConverter(org.hibernate.metamodel.model.convert.spi.BasicValueConverter) CollectionPersister(org.hibernate.persister.collection.CollectionPersister) Collections(java.util.Collections) SelectableConsumer(org.hibernate.metamodel.mapping.SelectableConsumer) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) IndexedConsumer(org.hibernate.mapping.IndexedConsumer) FetchParent(org.hibernate.sql.results.graph.FetchParent) TableReference(org.hibernate.sql.ast.tree.from.TableReference) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference)

Aggregations

PluralTableGroup (org.hibernate.sql.ast.tree.from.PluralTableGroup)6 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)5 NavigablePath (org.hibernate.query.spi.NavigablePath)4 Collections (java.util.Collections)3 BiConsumer (java.util.function.BiConsumer)3 FetchTiming (org.hibernate.engine.FetchTiming)3 BasicValuedModelPart (org.hibernate.metamodel.mapping.BasicValuedModelPart)3 CollectionPart (org.hibernate.metamodel.mapping.CollectionPart)3 CorrelatedPluralTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedPluralTableGroup)3 CorrelatedTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedTableGroup)3 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ConvertibleModelPart (org.hibernate.metamodel.mapping.ConvertibleModelPart)2 EmbeddableValuedModelPart (org.hibernate.metamodel.mapping.EmbeddableValuedModelPart)2 EntityMappingType (org.hibernate.metamodel.mapping.EntityMappingType)2 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)2 ModelPart (org.hibernate.metamodel.mapping.ModelPart)2