Search in sources :

Example 11 with JavaType

use of org.hibernate.type.descriptor.java.JavaType in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method visitLiteral.

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// General expressions
@Override
public Expression visitLiteral(SqmLiteral<?> literal) {
    if (literal instanceof SqmLiteralNull) {
        MappingModelExpressible<?> mappingModelExpressible = resolveInferredType();
        if (mappingModelExpressible == null) {
            mappingModelExpressible = determineCurrentExpressible(literal);
        }
        if (mappingModelExpressible instanceof BasicValuedMapping) {
            return new QueryLiteral<>(null, (BasicValuedMapping) mappingModelExpressible);
        }
        final MappingModelExpressible<?> keyExpressible = getKeyExpressible(mappingModelExpressible);
        if (keyExpressible == null) {
            // Default to the Object type
            return new QueryLiteral<>(null, basicType(Object.class));
        }
        final List<Expression> expressions = new ArrayList<>(keyExpressible.getJdbcTypeCount());
        keyExpressible.forEachJdbcType((index, jdbcMapping) -> expressions.add(new QueryLiteral<>(null, (BasicValuedMapping) jdbcMapping)));
        return new SqlTuple(expressions, mappingModelExpressible);
    }
    final MappingModelExpressible<?> inferableExpressible = resolveInferredType();
    if (inferableExpressible instanceof ConvertibleModelPart) {
        final ConvertibleModelPart convertibleModelPart = (ConvertibleModelPart) inferableExpressible;
        if (convertibleModelPart.getValueConverter() != null) {
            return new QueryLiteral<>(literal.getLiteralValue(), convertibleModelPart);
        }
    } else // Special case for when we create an entity literal through the JPA CriteriaBuilder.literal API
    if (inferableExpressible instanceof EntityDiscriminatorMapping) {
        final EntityDiscriminatorMapping discriminatorMapping = (EntityDiscriminatorMapping) inferableExpressible;
        final Object literalValue = literal.getLiteralValue();
        final EntityPersister mappingDescriptor;
        if (literalValue instanceof Class<?>) {
            mappingDescriptor = creationContext.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor((Class<?>) literalValue);
        } else {
            final JavaType<?> javaType = discriminatorMapping.getJdbcMapping().getJavaTypeDescriptor();
            final Object discriminatorValue;
            if (javaType.getJavaTypeClass().isInstance(literalValue)) {
                discriminatorValue = literalValue;
            } else if (literalValue instanceof CharSequence) {
                discriminatorValue = javaType.fromString((CharSequence) literalValue);
            } else if (creationContext.getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled()) {
                discriminatorValue = literalValue;
            } else {
                discriminatorValue = javaType.coerce(literalValue, null);
            }
            final String entityName = discriminatorMapping.getConcreteEntityNameForDiscriminatorValue(discriminatorValue);
            mappingDescriptor = creationContext.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(entityName);
        }
        return new EntityTypeLiteral(mappingDescriptor);
    }
    final MappingModelExpressible<?> expressible;
    final MappingModelExpressible<?> localExpressible = SqmMappingModelHelper.resolveMappingModelExpressible(literal, creationContext.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel(), getFromClauseAccess()::findTableGroup);
    if (localExpressible == null) {
        expressible = getElementExpressible(inferableExpressible);
    } else {
        final MappingModelExpressible<?> elementExpressible = getElementExpressible(localExpressible);
        if (elementExpressible instanceof BasicType) {
            expressible = InferredBasicValueResolver.resolveSqlTypeIndicators(this, (BasicType) elementExpressible, literal.getJavaTypeDescriptor());
        } else {
            expressible = elementExpressible;
        }
    }
    if (expressible instanceof EntityIdentifierMapping && literal.getNodeType() instanceof EntityTypeImpl) {
        return new QueryLiteral<>(((EntityIdentifierMapping) expressible).getIdentifier(literal.getLiteralValue()), (BasicValuedMapping) expressible);
    }
    if (expressible instanceof BasicValuedMapping) {
        return new QueryLiteral<>(literal.getLiteralValue(), (BasicValuedMapping) expressible);
    }
    // Handling other values might seem unnecessary, but with JPA Criteria it is totally possible to have such literals
    if (expressible instanceof EmbeddableValuedModelPart) {
        final EmbeddableValuedModelPart embeddableValuedModelPart = (EmbeddableValuedModelPart) expressible;
        final List<Expression> list = new ArrayList<>(embeddableValuedModelPart.getJdbcTypeCount());
        embeddableValuedModelPart.forEachJdbcValue(literal.getLiteralValue(), null, (selectionIndex, value, jdbcMapping) -> list.add(new QueryLiteral<>(value, (BasicValuedMapping) jdbcMapping)), null);
        return new SqlTuple(list, expressible);
    } else if (expressible instanceof EntityValuedModelPart) {
        final EntityValuedModelPart entityValuedModelPart = (EntityValuedModelPart) expressible;
        final Object associationKey;
        final ModelPart associationKeyPart;
        if (entityValuedModelPart instanceof Association) {
            final Association association = (Association) entityValuedModelPart;
            final ForeignKeyDescriptor foreignKeyDescriptor = association.getForeignKeyDescriptor();
            associationKey = foreignKeyDescriptor.getAssociationKeyFromSide(literal.getLiteralValue(), association.getSideNature().inverse(), null);
            associationKeyPart = foreignKeyDescriptor.getPart(association.getSideNature());
        } else {
            final EntityIdentifierMapping identifierMapping = entityValuedModelPart.getEntityMappingType().getIdentifierMapping();
            associationKeyPart = identifierMapping;
            associationKey = identifierMapping.getIdentifier(literal.getLiteralValue(), null);
        }
        if (associationKeyPart instanceof BasicValuedMapping) {
            return new QueryLiteral<>(associationKey, (BasicValuedMapping) associationKeyPart);
        } else {
            final List<Expression> list = new ArrayList<>(associationKeyPart.getJdbcTypeCount());
            associationKeyPart.forEachJdbcValue(associationKey, null, (selectionIndex, value, jdbcMapping) -> list.add(new QueryLiteral<>(value, (BasicValuedMapping) jdbcMapping)), null);
            return new SqlTuple(list, associationKeyPart);
        }
    } else {
        return new QueryLiteral<>(literal.getLiteralValue(), creationContext.getSessionFactory().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType(((BasicSqmPathSource<?>) literal.getNodeType()).getSqmPathType().getJavaType().getName()));
    }
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) SingleTableEntityPersister(org.hibernate.persister.entity.SingleTableEntityPersister) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) 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) EntityTypeLiteral(org.hibernate.sql.ast.tree.expression.EntityTypeLiteral) BasicType(org.hibernate.type.BasicType) ConvertibleModelPart(org.hibernate.metamodel.mapping.ConvertibleModelPart) ModelPart(org.hibernate.metamodel.mapping.ModelPart) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) BasicValuedModelPart(org.hibernate.metamodel.mapping.BasicValuedModelPart) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) SqmLiteralNull(org.hibernate.query.sqm.tree.expression.SqmLiteralNull) ArrayList(java.util.ArrayList) QueryLiteral(org.hibernate.sql.ast.tree.expression.QueryLiteral) ConvertedQueryLiteral(org.hibernate.sql.ast.tree.expression.ConvertedQueryLiteral) ConvertibleModelPart(org.hibernate.metamodel.mapping.ConvertibleModelPart) Association(org.hibernate.metamodel.mapping.Association) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) EntityTypeImpl(org.hibernate.metamodel.model.domain.internal.EntityTypeImpl) ArrayList(java.util.ArrayList) List(java.util.List) EntityDiscriminatorMapping(org.hibernate.metamodel.mapping.EntityDiscriminatorMapping) BasicValuedMapping(org.hibernate.metamodel.mapping.BasicValuedMapping) BasicJavaType(org.hibernate.type.descriptor.java.BasicJavaType) JavaType(org.hibernate.type.descriptor.java.JavaType) EnumJavaType(org.hibernate.type.descriptor.java.EnumJavaType) BinaryArithmeticExpression(org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression) SqmModifiedSubQueryExpression(org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression) SelfRenderingFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression) SelfRenderingAggregateFunctionSqlAstExpression(org.hibernate.query.sqm.function.SelfRenderingAggregateFunctionSqlAstExpression) CaseSearchedExpression(org.hibernate.sql.ast.tree.expression.CaseSearchedExpression) SelfRenderingSqlFragmentExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingSqlFragmentExpression) Expression(org.hibernate.sql.ast.tree.expression.Expression) SelfRenderingExpression(org.hibernate.sql.ast.tree.expression.SelfRenderingExpression) SqmExpression(org.hibernate.query.sqm.tree.expression.SqmExpression) CaseSimpleExpression(org.hibernate.sql.ast.tree.expression.CaseSimpleExpression) SqlSelectionExpression(org.hibernate.sql.ast.tree.expression.SqlSelectionExpression) ModifiedSubQueryExpression(org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression) EntityIdentifierMapping(org.hibernate.metamodel.mapping.EntityIdentifierMapping) BasicEntityIdentifierMapping(org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) SqlTuple(org.hibernate.sql.ast.tree.expression.SqlTuple)

Example 12 with JavaType

use of org.hibernate.type.descriptor.java.JavaType in project hibernate-orm by hibernate.

the class AbstractEntityPersister method generateNonIdAttributeMapping.

private AttributeMapping generateNonIdAttributeMapping(NonIdentifierAttribute tupleAttrDefinition, Property bootProperty, int stateArrayPosition, MappingModelCreationProcess creationProcess) {
    final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
    final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
    final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
    final Dialect dialect = jdbcEnvironment.getDialect();
    final String attrName = tupleAttrDefinition.getName();
    final Type attrType = tupleAttrDefinition.getType();
    final int propertyIndex = getPropertyIndex(bootProperty.getName());
    final String tableExpression = getTableName(getPropertyTableNumbers()[propertyIndex]);
    final String[] attrColumnNames = getPropertyColumnNames(propertyIndex);
    final PropertyAccess propertyAccess = getRepresentationStrategy().resolvePropertyAccess(bootProperty);
    if (propertyIndex == getVersionProperty()) {
        Column column = bootProperty.getValue().getColumns().get(0);
        return MappingModelCreationHelper.buildBasicAttributeMapping(attrName, getNavigableRole().append(bootProperty.getName()), stateArrayPosition, bootProperty, this, (BasicType<?>) attrType, tableExpression, attrColumnNames[0], false, null, null, column.getSqlType(), column.getLength(), column.getPrecision(), column.getScale(), propertyAccess, tupleAttrDefinition.getCascadeStyle(), creationProcess);
    }
    if (attrType instanceof BasicType) {
        final Value bootValue = bootProperty.getValue();
        final String attrColumnExpression;
        final boolean isAttrColumnExpressionFormula;
        final String customReadExpr;
        final String customWriteExpr;
        final String columnDefinition;
        final Long length;
        final Integer precision;
        final Integer scale;
        if (bootValue instanceof DependantValue) {
            attrColumnExpression = attrColumnNames[0];
            isAttrColumnExpressionFormula = false;
            customReadExpr = null;
            customWriteExpr = null;
            Column column = bootValue.getColumns().get(0);
            columnDefinition = column.getSqlType();
            length = column.getLength();
            precision = column.getPrecision();
            scale = column.getScale();
        } else {
            final BasicValue basicBootValue = (BasicValue) bootValue;
            if (attrColumnNames[0] != null) {
                attrColumnExpression = attrColumnNames[0];
                isAttrColumnExpressionFormula = false;
                final List<Selectable> selectables = basicBootValue.getSelectables();
                assert !selectables.isEmpty();
                final Selectable selectable = selectables.get(0);
                assert attrColumnExpression.equals(selectable.getText(sessionFactory.getJdbcServices().getDialect()));
                customReadExpr = selectable.getTemplate(dialect, sessionFactory.getQueryEngine().getSqmFunctionRegistry());
                customWriteExpr = selectable.getCustomWriteExpression();
                Column column = bootValue.getColumns().get(0);
                columnDefinition = column.getSqlType();
                length = column.getLength();
                precision = column.getPrecision();
                scale = column.getScale();
            } else {
                final String[] attrColumnFormulaTemplate = propertyColumnFormulaTemplates[propertyIndex];
                attrColumnExpression = attrColumnFormulaTemplate[0];
                isAttrColumnExpressionFormula = true;
                customReadExpr = null;
                customWriteExpr = null;
                columnDefinition = null;
                length = null;
                precision = null;
                scale = null;
            }
        }
        return MappingModelCreationHelper.buildBasicAttributeMapping(attrName, getNavigableRole().append(bootProperty.getName()), stateArrayPosition, bootProperty, this, (BasicType<?>) attrType, tableExpression, attrColumnExpression, isAttrColumnExpressionFormula, customReadExpr, customWriteExpr, columnDefinition, length, precision, scale, propertyAccess, tupleAttrDefinition.getCascadeStyle(), creationProcess);
    } else if (attrType instanceof AnyType) {
        final JavaType<Object> baseAssociationJtd = sessionFactory.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class);
        final AnyType anyType = (AnyType) attrType;
        return new DiscriminatedAssociationAttributeMapping(navigableRole.append(bootProperty.getName()), baseAssociationJtd, this, stateArrayPosition, entityMappingType -> new StateArrayContributorMetadata() {

            private final MutabilityPlan<?> mutabilityPlan = new DiscriminatedAssociationAttributeMapping.MutabilityPlanImpl(anyType);

            private final boolean nullable = bootProperty.isOptional();

            private final boolean insertable = bootProperty.isInsertable();

            private final boolean updateable = bootProperty.isUpdateable();

            private final boolean optimisticallyLocked = bootProperty.isOptimisticLocked();

            @Override
            public PropertyAccess getPropertyAccess() {
                return propertyAccess;
            }

            @Override
            public MutabilityPlan<?> getMutabilityPlan() {
                return mutabilityPlan;
            }

            @Override
            public boolean isNullable() {
                return nullable;
            }

            @Override
            public boolean isInsertable() {
                return insertable;
            }

            @Override
            public boolean isUpdatable() {
                return updateable;
            }

            @Override
            public boolean isIncludedInDirtyChecking() {
                return updateable;
            }

            @Override
            public boolean isIncludedInOptimisticLocking() {
                return optimisticallyLocked;
            }
        }, bootProperty.isLazy() ? FetchTiming.DELAYED : FetchTiming.IMMEDIATE, propertyAccess, bootProperty, (AnyType) attrType, (Any) bootProperty.getValue(), creationProcess);
    } else if (attrType instanceof CompositeType) {
        return MappingModelCreationHelper.buildEmbeddedAttributeMapping(attrName, stateArrayPosition, bootProperty, this, (CompositeType) attrType, tableExpression, null, propertyAccess, tupleAttrDefinition.getCascadeStyle(), creationProcess);
    } else if (attrType instanceof CollectionType) {
        return MappingModelCreationHelper.buildPluralAttributeMapping(attrName, stateArrayPosition, bootProperty, this, propertyAccess, tupleAttrDefinition.getCascadeStyle(), getFetchMode(stateArrayPosition), creationProcess);
    } else if (attrType instanceof EntityType) {
        return MappingModelCreationHelper.buildSingularAssociationAttributeMapping(attrName, getNavigableRole().append(attrName), stateArrayPosition, bootProperty, this, this, (EntityType) attrType, propertyAccess, tupleAttrDefinition.getCascadeStyle(), creationProcess);
    }
    return null;
}
Also used : Alias(org.hibernate.sql.Alias) Property(org.hibernate.mapping.Property) SqlFragmentPredicate(org.hibernate.persister.internal.SqlFragmentPredicate) BasicType(org.hibernate.type.BasicType) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) ClassMetadata(org.hibernate.metadata.ClassMetadata) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) ReferenceCacheEntryImpl(org.hibernate.cache.spi.entry.ReferenceCacheEntryImpl) MappingModelCreationHelper(org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper) Expectations(org.hibernate.jdbc.Expectations) PostInsertIdentifierGenerator(org.hibernate.id.PostInsertIdentifierGenerator) Map(java.util.Map) EntityVersionMapping(org.hibernate.metamodel.mapping.EntityVersionMapping) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) IdentifierGenerator(org.hibernate.id.IdentifierGenerator) Optimizer(org.hibernate.id.enhanced.Optimizer) SingleIdEntityLoader(org.hibernate.loader.ast.spi.SingleIdEntityLoader) GeneratedValuesProcessor(org.hibernate.metamodel.mapping.internal.GeneratedValuesProcessor) NavigablePath(org.hibernate.query.spi.NavigablePath) LazyAttributeDescriptor(org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeDescriptor) Value(org.hibernate.mapping.Value) PreparedStatement(java.sql.PreparedStatement) SimpleFromClauseAccessImpl(org.hibernate.sql.ast.spi.SimpleFromClauseAccessImpl) Subclass(org.hibernate.mapping.Subclass) SqlAliasBase(org.hibernate.sql.ast.spi.SqlAliasBase) Serializable(java.io.Serializable) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) CacheHelper(org.hibernate.engine.internal.CacheHelper) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) PersisterCreationContext(org.hibernate.persister.spi.PersisterCreationContext) SqmMutationStrategyHelper(org.hibernate.query.sqm.mutation.internal.SqmMutationStrategyHelper) TooManyRowsAffectedException(org.hibernate.jdbc.TooManyRowsAffectedException) Dialect(org.hibernate.dialect.Dialect) CascadeStyle(org.hibernate.engine.spi.CascadeStyle) FetchMode(org.hibernate.FetchMode) UnstructuredCacheEntry(org.hibernate.cache.spi.entry.UnstructuredCacheEntry) CollectionPersister(org.hibernate.persister.collection.CollectionPersister) EnhancementHelper(org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper) SelfDirtinessTracker(org.hibernate.engine.spi.SelfDirtinessTracker) EmbeddedAttributeMapping(org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping) SimpleNaturalIdMapping(org.hibernate.metamodel.mapping.internal.SimpleNaturalIdMapping) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) AssertionFailure(org.hibernate.AssertionFailure) SingleIdEntityLoaderDynamicBatch(org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch) FilterHelper(org.hibernate.internal.FilterHelper) QueryOptions(org.hibernate.query.spi.QueryOptions) Session(org.hibernate.Session) SessionFactoryOptions(org.hibernate.boot.spi.SessionFactoryOptions) EntityDataAccess(org.hibernate.cache.spi.access.EntityDataAccess) Metadata(org.hibernate.boot.Metadata) Supplier(java.util.function.Supplier) NaturalIdResolutions(org.hibernate.engine.spi.NaturalIdResolutions) SemanticException(org.hibernate.query.SemanticException) EntityVersionMappingImpl(org.hibernate.metamodel.mapping.internal.EntityVersionMappingImpl) LinkedHashMap(java.util.LinkedHashMap) NamedTableReference(org.hibernate.sql.ast.tree.from.NamedTableReference) MultiIdLoadOptions(org.hibernate.loader.ast.spi.MultiIdLoadOptions) Preparable(org.hibernate.loader.ast.internal.Preparable) DiscriminatedAssociationAttributeMapping(org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping) ToOneAttributeMapping(org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping) StandardTableGroup(org.hibernate.sql.ast.tree.from.StandardTableGroup) InFlightEntityMappingType(org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType) LoaderSelectBuilder(org.hibernate.loader.ast.internal.LoaderSelectBuilder) LazyAttributesMetadata(org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributesMetadata) SimpleSelect(org.hibernate.sql.SimpleSelect) EntityDiscriminatorMapping(org.hibernate.metamodel.mapping.EntityDiscriminatorMapping) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) EntityKey(org.hibernate.engine.spi.EntityKey) Table(org.hibernate.mapping.Table) Fetch(org.hibernate.sql.results.graph.Fetch) NaturalIdLoader(org.hibernate.loader.ast.spi.NaturalIdLoader) QueryableCollection(org.hibernate.persister.collection.QueryableCollection) Template(org.hibernate.sql.Template) FromClauseAccess(org.hibernate.sql.ast.spi.FromClauseAccess) TreeMap(java.util.TreeMap) BytecodeLazyAttributeInterceptor(org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor) NaturalIdMapping(org.hibernate.metamodel.mapping.NaturalIdMapping) SqlSelectionImpl(org.hibernate.sql.results.internal.SqlSelectionImpl) CachedNaturalIdValueSource(org.hibernate.engine.spi.CachedNaturalIdValueSource) AssociationType(org.hibernate.type.AssociationType) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) AnyType(org.hibernate.type.AnyType) EntityResultImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultImpl) SingleIdEntityLoaderStandardImpl(org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl) PersistentCollection(org.hibernate.collection.spi.PersistentCollection) LockModeEnumMap(org.hibernate.internal.util.collections.LockModeEnumMap) Locale(java.util.Locale) Binder(org.hibernate.id.insert.Binder) ComparisonOperator(org.hibernate.query.sqm.ComparisonOperator) LazyPropertyInitializer(org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer) PersistentAttributeInterceptable(org.hibernate.engine.spi.PersistentAttributeInterceptable) Formula(org.hibernate.mapping.Formula) Collection(java.util.Collection) StaleObjectStateException(org.hibernate.StaleObjectStateException) Column(org.hibernate.mapping.Column) StatisticsImplementor(org.hibernate.stat.spi.StatisticsImplementor) BasicBatchKey(org.hibernate.engine.jdbc.batch.internal.BasicBatchKey) Objects(java.util.Objects) ArrayHelper(org.hibernate.internal.util.collections.ArrayHelper) EntityRowIdMappingImpl(org.hibernate.metamodel.mapping.internal.EntityRowIdMappingImpl) Queryable(org.hibernate.metamodel.mapping.Queryable) Update(org.hibernate.sql.Update) LoaderSqlAstCreationState(org.hibernate.loader.ast.internal.LoaderSqlAstCreationState) SelectableConsumer(org.hibernate.metamodel.mapping.SelectableConsumer) IndexedConsumer(org.hibernate.mapping.IndexedConsumer) DomainResultCreationState(org.hibernate.sql.results.graph.DomainResultCreationState) OptimisticLockStyle(org.hibernate.engine.OptimisticLockStyle) CacheEntityLoaderHelper(org.hibernate.loader.entity.CacheEntityLoaderHelper) JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) RootClass(org.hibernate.mapping.RootClass) OptimizableGenerator(org.hibernate.id.OptimizableGenerator) TableReference(org.hibernate.sql.ast.tree.from.TableReference) HashSet(java.util.HashSet) ModelPart(org.hibernate.metamodel.mapping.ModelPart) Loader(org.hibernate.loader.ast.spi.Loader) CompositeType(org.hibernate.type.CompositeType) ManagedMappingType(org.hibernate.metamodel.mapping.ManagedMappingType) LockingStrategy(org.hibernate.dialect.lock.LockingStrategy) DiscriminatedAssociationModelPart(org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart) SqlAliasBaseManager(org.hibernate.sql.ast.spi.SqlAliasBaseManager) InsertGeneratedIdentifierDelegate(org.hibernate.id.insert.InsertGeneratedIdentifierDelegate) EntityEntryFactory(org.hibernate.engine.spi.EntityEntryFactory) SqmFunctionRegistry(org.hibernate.query.sqm.function.SqmFunctionRegistry) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) MappingModelCreationProcess(org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess) Consumer(java.util.function.Consumer) EntityRepresentationStrategy(org.hibernate.metamodel.spi.EntityRepresentationStrategy) JdbcParameter(org.hibernate.sql.ast.tree.expression.JdbcParameter) SelectableMapping(org.hibernate.metamodel.mapping.SelectableMapping) Selectable(org.hibernate.mapping.Selectable) NonAggregatedIdentifierMapping(org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping) EntityEntry(org.hibernate.engine.spi.EntityEntry) BitSet(java.util.BitSet) Comparator(java.util.Comparator) MutableEntityEntryFactory(org.hibernate.engine.internal.MutableEntityEntryFactory) MultiIdLoaderStandard(org.hibernate.loader.ast.internal.MultiIdLoaderStandard) Arrays(java.util.Arrays) EventSource(org.hibernate.event.spi.EventSource) ReflectionOptimizer(org.hibernate.bytecode.spi.ReflectionOptimizer) PersistenceContext(org.hibernate.engine.spi.PersistenceContext) PropertyAccess(org.hibernate.property.access.spi.PropertyAccess) SingleUniqueKeyEntityLoaderStandard(org.hibernate.loader.ast.internal.SingleUniqueKeyEntityLoaderStandard) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) PersistentClass(org.hibernate.mapping.PersistentClass) ResultSet(java.sql.ResultSet) MultiIdEntityLoader(org.hibernate.loader.ast.spi.MultiIdEntityLoader) LazyAttributeLoadingInterceptor(org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor) Insert(org.hibernate.sql.Insert) StaleStateException(org.hibernate.StaleStateException) SingleUniqueKeyEntityLoader(org.hibernate.loader.ast.spi.SingleUniqueKeyEntityLoader) BytecodeEnhancementMetadata(org.hibernate.bytecode.spi.BytecodeEnhancementMetadata) Fetchable(org.hibernate.sql.results.graph.Fetchable) StructuredCacheEntry(org.hibernate.cache.spi.entry.StructuredCacheEntry) LockOptions(org.hibernate.LockOptions) ImmutableEntityEntryFactory(org.hibernate.engine.internal.ImmutableEntityEntryFactory) StringHelper(org.hibernate.internal.util.StringHelper) Set(java.util.Set) Expression(org.hibernate.sql.ast.tree.expression.Expression) SingleIdArrayLoadPlan(org.hibernate.loader.ast.internal.SingleIdArrayLoadPlan) Assigned(org.hibernate.id.Assigned) LazyValue(org.hibernate.internal.util.LazyValue) EntityIdentifierMapping(org.hibernate.metamodel.mapping.EntityIdentifierMapping) BasicEntityIdentifierMappingImpl(org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl) Expectation(org.hibernate.jdbc.Expectation) RuntimeModelCreationContext(org.hibernate.metamodel.spi.RuntimeModelCreationContext) EnhancementAsProxyLazinessInterceptor(org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor) HibernateException(org.hibernate.HibernateException) CacheEntryStructure(org.hibernate.cache.spi.entry.CacheEntryStructure) QueryException(org.hibernate.QueryException) StateArrayContributorMapping(org.hibernate.metamodel.mapping.StateArrayContributorMapping) MutabilityPlan(org.hibernate.type.descriptor.java.MutabilityPlan) JavaType(org.hibernate.type.descriptor.java.JavaType) Setter(org.hibernate.property.access.spi.Setter) Clause(org.hibernate.sql.ast.Clause) ArrayList(java.util.ArrayList) StandardCacheEntryImpl(org.hibernate.cache.spi.entry.StandardCacheEntryImpl) ValueGeneration(org.hibernate.tuple.ValueGeneration) SQLException(java.sql.SQLException) BiConsumer(java.util.function.BiConsumer) PostInsertIdentityPersister(org.hibernate.id.PostInsertIdentityPersister) FetchTiming(org.hibernate.engine.FetchTiming) BulkInsertionCapableIdentifierGenerator(org.hibernate.id.BulkInsertionCapableIdentifierGenerator) SingularAttributeMapping(org.hibernate.metamodel.mapping.SingularAttributeMapping) Delete(org.hibernate.sql.Delete) StatefulPersistenceContext(org.hibernate.engine.internal.StatefulPersistenceContext) CompoundNaturalIdMapping(org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping) LoadEvent(org.hibernate.event.spi.LoadEvent) MultiNaturalIdLoader(org.hibernate.loader.ast.spi.MultiNaturalIdLoader) CollectionHelper(org.hibernate.internal.util.collections.CollectionHelper) NamedQueryMemento(org.hibernate.query.named.NamedQueryMemento) SqmMultiTableMutationStrategy(org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy) Filter(org.hibernate.Filter) SQLQueryParser(org.hibernate.query.sql.internal.SQLQueryParser) Lifecycle(org.hibernate.classic.Lifecycle) MessageHelper(org.hibernate.pretty.MessageHelper) Any(org.hibernate.mapping.Any) EntityBasedAssociationAttribute(org.hibernate.tuple.entity.EntityBasedAssociationAttribute) MappingModelHelper(org.hibernate.metamodel.mapping.MappingModelHelper) SqlAstCreationContext(org.hibernate.sql.ast.spi.SqlAstCreationContext) NonIdentifierAttribute(org.hibernate.tuple.NonIdentifierAttribute) ComparisonPredicate(org.hibernate.sql.ast.tree.predicate.ComparisonPredicate) JDBCException(org.hibernate.JDBCException) PersistentAttributeInterceptor(org.hibernate.engine.spi.PersistentAttributeInterceptor) ExecuteUpdateResultCheckStyle(org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle) TableReferenceJoin(org.hibernate.sql.ast.tree.from.TableReferenceJoin) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) CacheEntry(org.hibernate.cache.spi.entry.CacheEntry) AttributeMetadataAccess(org.hibernate.metamodel.mapping.AttributeMetadataAccess) IdentityHashMap(java.util.IdentityHashMap) DependantValue(org.hibernate.mapping.DependantValue) VirtualModelPart(org.hibernate.metamodel.mapping.VirtualModelPart) DomainResult(org.hibernate.sql.results.graph.DomainResult) SqmMultiTableInsertStrategy(org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) List(java.util.List) EntityInstantiator(org.hibernate.metamodel.spi.EntityInstantiator) SingleIdEntityLoaderProvidedQueryImpl(org.hibernate.loader.ast.internal.SingleIdEntityLoaderProvidedQueryImpl) MappingException(org.hibernate.MappingException) BasicValue(org.hibernate.mapping.BasicValue) SessionImplementor(org.hibernate.engine.spi.SessionImplementor) QuerySpec(org.hibernate.sql.ast.tree.select.QuerySpec) SortedMap(java.util.SortedMap) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) BasicValuedModelPart(org.hibernate.metamodel.mapping.BasicValuedModelPart) CoreMessageLogger(org.hibernate.internal.CoreMessageLogger) Junction(org.hibernate.sql.ast.tree.predicate.Junction) InDatabaseValueGenerationStrategy(org.hibernate.tuple.InDatabaseValueGenerationStrategy) ColumnReference(org.hibernate.sql.ast.tree.expression.ColumnReference) CollectionType(org.hibernate.type.CollectionType) HashMap(java.util.HashMap) SqlAliasStemHelper(org.hibernate.sql.ast.spi.SqlAliasStemHelper) InMemoryValueGenerationStrategy(org.hibernate.tuple.InMemoryValueGenerationStrategy) EntityType(org.hibernate.type.EntityType) RepresentationMode(org.hibernate.metamodel.RepresentationMode) FilterAliasGenerator(org.hibernate.internal.FilterAliasGenerator) AttributeMetadata(org.hibernate.metamodel.mapping.AttributeMetadata) SqlAliasBaseConstant(org.hibernate.sql.ast.spi.SqlAliasBaseConstant) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) LockMode(org.hibernate.LockMode) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate) Versioning(org.hibernate.engine.internal.Versioning) AliasedExpression(org.hibernate.sql.ast.tree.expression.AliasedExpression) ExplicitColumnDiscriminatorMappingImpl(org.hibernate.metamodel.mapping.internal.ExplicitColumnDiscriminatorMappingImpl) SelectClause(org.hibernate.sql.ast.tree.select.SelectClause) Association(org.hibernate.metamodel.mapping.Association) EntityRowIdMapping(org.hibernate.metamodel.mapping.EntityRowIdMapping) GenerationTiming(org.hibernate.tuple.GenerationTiming) Component(org.hibernate.mapping.Component) CollectionKey(org.hibernate.engine.spi.CollectionKey) StateArrayContributorMetadata(org.hibernate.metamodel.mapping.StateArrayContributorMetadata) LazyInitializationException(org.hibernate.LazyInitializationException) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) NaturalIdDataAccess(org.hibernate.cache.spi.access.NaturalIdDataAccess) AttributeMapping(org.hibernate.metamodel.mapping.AttributeMapping) Collections(java.util.Collections) CoreLogging(org.hibernate.internal.CoreLogging) Type(org.hibernate.type.Type) BasicType(org.hibernate.type.BasicType) DiscriminatedAssociationAttributeMapping(org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping) JdbcServices(org.hibernate.engine.jdbc.spi.JdbcServices) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) Any(org.hibernate.mapping.Any) BasicValue(org.hibernate.mapping.BasicValue) Column(org.hibernate.mapping.Column) Selectable(org.hibernate.mapping.Selectable) CollectionType(org.hibernate.type.CollectionType) Dialect(org.hibernate.dialect.Dialect) MutabilityPlan(org.hibernate.type.descriptor.java.MutabilityPlan) AnyType(org.hibernate.type.AnyType) DependantValue(org.hibernate.mapping.DependantValue) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) StateArrayContributorMetadata(org.hibernate.metamodel.mapping.StateArrayContributorMetadata) PropertyAccess(org.hibernate.property.access.spi.PropertyAccess) EntityType(org.hibernate.type.EntityType) BasicType(org.hibernate.type.BasicType) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) InFlightEntityMappingType(org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType) AssociationType(org.hibernate.type.AssociationType) AnyType(org.hibernate.type.AnyType) CompositeType(org.hibernate.type.CompositeType) ManagedMappingType(org.hibernate.metamodel.mapping.ManagedMappingType) JavaType(org.hibernate.type.descriptor.java.JavaType) CollectionType(org.hibernate.type.CollectionType) EntityType(org.hibernate.type.EntityType) Type(org.hibernate.type.Type) JavaType(org.hibernate.type.descriptor.java.JavaType) Value(org.hibernate.mapping.Value) LazyValue(org.hibernate.internal.util.LazyValue) DependantValue(org.hibernate.mapping.DependantValue) BasicValue(org.hibernate.mapping.BasicValue) CompositeType(org.hibernate.type.CompositeType)

Example 13 with JavaType

use of org.hibernate.type.descriptor.java.JavaType in project hibernate-orm by hibernate.

the class ListResultsConsumer method consume.

@Override
public List<R> consume(JdbcValues jdbcValues, SharedSessionContractImplementor session, JdbcValuesSourceProcessingOptions processingOptions, JdbcValuesSourceProcessingStateStandardImpl jdbcValuesSourceProcessingState, RowProcessingStateStandardImpl rowProcessingState, RowReader<R> rowReader) {
    final PersistenceContext persistenceContext = session.getPersistenceContext();
    RuntimeException ex = null;
    try {
        persistenceContext.getLoadContexts().register(jdbcValuesSourceProcessingState);
        final List<R> results = new ArrayList<>();
        boolean uniqueRows = false;
        if (uniqueSemantic != UniqueSemantic.NONE) {
            final Class<R> resultJavaType = rowReader.getResultJavaType();
            if (resultJavaType != null && !resultJavaType.isArray()) {
                final EntityPersister entityDescriptor = session.getFactory().getRuntimeMetamodels().getMappingMetamodel().findEntityDescriptor(resultJavaType);
                if (entityDescriptor != null) {
                    uniqueRows = true;
                }
            }
        }
        if (uniqueRows) {
            final List<JavaType> resultJavaTypes = rowReader.getResultJavaTypes();
            assert resultJavaTypes.size() == 1;
            final JavaType<R> resultJavaType = resultJavaTypes.get(0);
            while (rowProcessingState.next()) {
                final R row = rowReader.readRow(rowProcessingState, processingOptions);
                boolean add = true;
                for (R existingRow : results) {
                    if (resultJavaType.areEqual(existingRow, row)) {
                        if (uniqueSemantic == UniqueSemantic.ASSERT && !rowProcessingState.hasCollectionInitializers()) {
                            throw new HibernateException("More than one row with the given identifier was found: " + jdbcValuesSourceProcessingState.getExecutionContext().getEntityId() + ", for class: " + rowReader.getResultJavaType().getName());
                        }
                        add = false;
                        break;
                    }
                }
                if (add) {
                    results.add(row);
                }
                rowProcessingState.finishRowProcessing();
            }
        } else {
            while (rowProcessingState.next()) {
                results.add(rowReader.readRow(rowProcessingState, processingOptions));
                rowProcessingState.finishRowProcessing();
            }
        }
        try {
            jdbcValuesSourceProcessingState.finishUp();
        } finally {
            persistenceContext.getLoadContexts().deregister(jdbcValuesSourceProcessingState);
        }
        // noinspection unchecked
        final ResultListTransformer<R> resultListTransformer = (ResultListTransformer<R>) jdbcValuesSourceProcessingState.getExecutionContext().getQueryOptions().getResultListTransformer();
        if (resultListTransformer != null) {
            return resultListTransformer.transformList(results);
        }
        return results;
    } catch (RuntimeException e) {
        ex = e;
    } finally {
        try {
            rowReader.finishUp(jdbcValuesSourceProcessingState);
            jdbcValues.finishUp(session);
            persistenceContext.initializeNonLazyCollections();
        } catch (RuntimeException e) {
            if (ex != null) {
                ex.addSuppressed(e);
            } else {
                ex = e;
            }
        } finally {
            if (ex != null) {
                throw ex;
            }
        }
    }
    throw new IllegalStateException("Should not reach this!");
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) PersistenceContext(org.hibernate.engine.spi.PersistenceContext) JavaType(org.hibernate.type.descriptor.java.JavaType) ResultListTransformer(org.hibernate.query.ResultListTransformer)

Aggregations

JavaType (org.hibernate.type.descriptor.java.JavaType)13 BasicType (org.hibernate.type.BasicType)6 TypeConfiguration (org.hibernate.type.spi.TypeConfiguration)6 SqlExpressionResolver (org.hibernate.sql.ast.spi.SqlExpressionResolver)5 SqlSelection (org.hibernate.sql.ast.spi.SqlSelection)5 JdbcType (org.hibernate.type.descriptor.jdbc.JdbcType)5 SqlAstCreationState (org.hibernate.sql.ast.spi.SqlAstCreationState)4 BasicJavaType (org.hibernate.type.descriptor.java.BasicJavaType)4 ArrayList (java.util.ArrayList)3 BiConsumer (java.util.function.BiConsumer)3 HibernateException (org.hibernate.HibernateException)3 FetchTiming (org.hibernate.engine.FetchTiming)3 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)3 UserType (org.hibernate.usertype.UserType)3 TemporalType (jakarta.persistence.TemporalType)2 Serializable (java.io.Serializable)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2