Search in sources :

Example 1 with FunctionArgumentTypeResolver

use of org.hibernate.query.sqm.produce.function.FunctionArgumentTypeResolver in project hibernate-orm by hibernate.

the class SelfRenderingSqmFunction method resolveSqlAstArguments.

protected List<SqlAstNode> resolveSqlAstArguments(List<? extends SqmTypedNode<?>> sqmArguments, SqmToSqlAstConverter walker) {
    if (sqmArguments == null || sqmArguments.isEmpty()) {
        return emptyList();
    }
    final FunctionArgumentTypeResolver argumentTypeResolver;
    if (getFunctionDescriptor() instanceof AbstractSqmFunctionDescriptor) {
        argumentTypeResolver = ((AbstractSqmFunctionDescriptor) getFunctionDescriptor()).getArgumentTypeResolver();
    } else {
        argumentTypeResolver = null;
    }
    if (argumentTypeResolver == null) {
        final ArrayList<SqlAstNode> sqlAstArguments = new ArrayList<>(sqmArguments.size());
        for (int i = 0; i < sqmArguments.size(); i++) {
            sqlAstArguments.add((SqlAstNode) ((SqmVisitableNode) sqmArguments.get(i)).accept(walker));
        }
        return sqlAstArguments;
    }
    final FunctionArgumentTypeResolverTypeAccess typeAccess = new FunctionArgumentTypeResolverTypeAccess(walker, this, argumentTypeResolver);
    final ArrayList<SqlAstNode> sqlAstArguments = new ArrayList<>(sqmArguments.size());
    for (int i = 0; i < sqmArguments.size(); i++) {
        typeAccess.argumentIndex = i;
        sqlAstArguments.add((SqlAstNode) walker.visitWithInferredType((SqmVisitableNode) sqmArguments.get(i), typeAccess));
    }
    return sqlAstArguments;
}
Also used : ArrayList(java.util.ArrayList) FunctionArgumentTypeResolver(org.hibernate.query.sqm.produce.function.FunctionArgumentTypeResolver) SqlAstNode(org.hibernate.sql.ast.tree.SqlAstNode) SqmVisitableNode(org.hibernate.query.sqm.tree.SqmVisitableNode)

Aggregations

ArrayList (java.util.ArrayList)1 FunctionArgumentTypeResolver (org.hibernate.query.sqm.produce.function.FunctionArgumentTypeResolver)1 SqmVisitableNode (org.hibernate.query.sqm.tree.SqmVisitableNode)1 SqlAstNode (org.hibernate.sql.ast.tree.SqlAstNode)1