Search in sources :

Example 1 with SqmAny

use of org.hibernate.query.sqm.tree.expression.SqmAny in project hibernate-orm by hibernate.

the class SemanticQueryBuilder method visitAnyFunction.

@Override
public SqmExpression<?> visitAnyFunction(HqlParser.AnyFunctionContext ctx) {
    final SqmPredicate filterExpression = getFilterExpression(ctx);
    final ParseTree argumentChild = ctx.getChild(2);
    if (argumentChild instanceof HqlParser.SubqueryContext) {
        final SqmSubQuery<?> subquery = (SqmSubQuery<?>) argumentChild.accept(this);
        return new SqmAny<>(subquery, creationContext.getNodeBuilder());
    } else if (argumentChild instanceof HqlParser.PredicateContext) {
        if (getCreationOptions().useStrictJpaCompliance()) {
            throw new StrictJpaComplianceViolation(StrictJpaComplianceViolation.Type.FUNCTION_CALL);
        }
        final SqmExpression<?> argument = (SqmExpression<?>) argumentChild.accept(this);
        return applyOverClause(ctx, getFunctionDescriptor("any").generateAggregateSqmExpression(singletonList(argument), filterExpression, resolveExpressibleTypeBasic(Boolean.class), creationContext.getQueryEngine(), creationContext.getJpaMetamodel().getTypeConfiguration()));
    } else {
        if (getCreationOptions().useStrictJpaCompliance()) {
            throw new StrictJpaComplianceViolation(StrictJpaComplianceViolation.Type.HQL_COLLECTION_FUNCTION);
        }
        return new SqmAny<>(createCollectionReferenceSubQuery((HqlParser.SimplePathContext) ctx.getChild(3), (TerminalNode) ctx.getChild(1)), creationContext.getNodeBuilder());
    }
}
Also used : SqmAny(org.hibernate.query.sqm.tree.expression.SqmAny) SqmPredicate(org.hibernate.query.sqm.tree.predicate.SqmPredicate) SqmSubQuery(org.hibernate.query.sqm.tree.select.SqmSubQuery) SqmExpression(org.hibernate.query.sqm.tree.expression.SqmExpression) HqlParser(org.hibernate.grammars.hql.HqlParser) StrictJpaComplianceViolation(org.hibernate.query.sqm.StrictJpaComplianceViolation) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ParseTree (org.antlr.v4.runtime.tree.ParseTree)1 HqlParser (org.hibernate.grammars.hql.HqlParser)1 StrictJpaComplianceViolation (org.hibernate.query.sqm.StrictJpaComplianceViolation)1 SqmAny (org.hibernate.query.sqm.tree.expression.SqmAny)1 SqmExpression (org.hibernate.query.sqm.tree.expression.SqmExpression)1 SqmPredicate (org.hibernate.query.sqm.tree.predicate.SqmPredicate)1 SqmSubQuery (org.hibernate.query.sqm.tree.select.SqmSubQuery)1