Search in sources :

Example 1 with SqmEvery

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

the class SemanticQueryBuilder method visitEveryFunction.

@Override
public SqmExpression<?> visitEveryFunction(HqlParser.EveryFunctionContext 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 SqmEvery<>(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("every").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 SqmEvery<>(createCollectionReferenceSubQuery((HqlParser.SimplePathContext) ctx.getChild(3), (TerminalNode) ctx.getChild(1)), creationContext.getNodeBuilder());
    }
}
Also used : 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) SqmEvery(org.hibernate.query.sqm.tree.expression.SqmEvery) 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 SqmEvery (org.hibernate.query.sqm.tree.expression.SqmEvery)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