Search in sources :

Example 1 with DynamicInstantiationNature

use of org.hibernate.query.sqm.DynamicInstantiationNature in project hibernate-orm by hibernate.

the class BaseSqmToSqlAstConverter method visitDynamicInstantiation.

@Override
public DynamicInstantiation<?> visitDynamicInstantiation(SqmDynamicInstantiation<?> sqmDynamicInstantiation) {
    final SqmDynamicInstantiationTarget<?> instantiationTarget = sqmDynamicInstantiation.getInstantiationTarget();
    final DynamicInstantiationNature instantiationNature = instantiationTarget.getNature();
    final JavaType<Object> targetTypeDescriptor = interpretInstantiationTarget(instantiationTarget);
    final DynamicInstantiation<?> dynamicInstantiation = new DynamicInstantiation<>(instantiationNature, targetTypeDescriptor);
    for (SqmDynamicInstantiationArgument<?> sqmArgument : sqmDynamicInstantiation.getArguments()) {
        final SqmSelectableNode<?> selectableNode = sqmArgument.getSelectableNode();
        if (selectableNode instanceof SqmPath<?>) {
            prepareForSelection((SqmPath<?>) selectableNode);
        }
        final DomainResultProducer<?> argumentResultProducer = (DomainResultProducer<?>) selectableNode.accept(this);
        dynamicInstantiation.addArgument(sqmArgument.getAlias(), argumentResultProducer, this);
    }
    dynamicInstantiation.complete();
    return dynamicInstantiation;
}
Also used : DynamicInstantiationNature(org.hibernate.query.sqm.DynamicInstantiationNature) DomainResultProducer(org.hibernate.query.sqm.sql.internal.DomainResultProducer) SelfInterpretingSqmPath(org.hibernate.query.sqm.sql.internal.SelfInterpretingSqmPath) SqmPath(org.hibernate.query.sqm.tree.domain.SqmPath) DiscriminatorSqmPath(org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPath) DynamicInstantiation(org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiation) SqmDynamicInstantiation(org.hibernate.query.sqm.tree.select.SqmDynamicInstantiation)

Aggregations

DiscriminatorSqmPath (org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPath)1 DynamicInstantiationNature (org.hibernate.query.sqm.DynamicInstantiationNature)1 DomainResultProducer (org.hibernate.query.sqm.sql.internal.DomainResultProducer)1 SelfInterpretingSqmPath (org.hibernate.query.sqm.sql.internal.SelfInterpretingSqmPath)1 SqmPath (org.hibernate.query.sqm.tree.domain.SqmPath)1 SqmDynamicInstantiation (org.hibernate.query.sqm.tree.select.SqmDynamicInstantiation)1 DynamicInstantiation (org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiation)1