Search in sources :

Example 1 with FunctionNode

use of org.hibernate.hql.internal.ast.tree.FunctionNode in project hibernate-orm by hibernate.

the class SqlGenerator method endFunctionTemplate.

@Override
protected void endFunctionTemplate(AST node) {
    FunctionNode functionNode = (FunctionNode) node;
    SQLFunction sqlFunction = functionNode.getSQLFunction();
    if (sqlFunction == null) {
        super.endFunctionTemplate(node);
    } else {
        final Type functionType = functionNode.getFirstArgumentType();
        // this function has a registered SQLFunction -> redirect output and catch the arguments
        FunctionArgumentsCollectingWriter functionArguments = (FunctionArgumentsCollectingWriter) writer;
        writer = outputStack.removeFirst();
        out(sqlFunction.render(functionType, functionArguments.getArgs(), sessionFactory));
    }
}
Also used : Type(org.hibernate.type.Type) FunctionNode(org.hibernate.hql.internal.ast.tree.FunctionNode) SQLFunction(org.hibernate.dialect.function.SQLFunction)

Example 2 with FunctionNode

use of org.hibernate.hql.internal.ast.tree.FunctionNode in project hibernate-orm by hibernate.

the class SqlGenerator method beginFunctionTemplate.

@Override
protected void beginFunctionTemplate(AST node, AST nameNode) {
    // NOTE for AGGREGATE both nodes are the same; for METHOD the first is the METHOD, the second is the
    // 		METHOD_NAME
    FunctionNode functionNode = (FunctionNode) node;
    SQLFunction sqlFunction = functionNode.getSQLFunction();
    if (sqlFunction == null) {
        // if SQLFunction is null we just write the function out as it appears in the hql statement
        super.beginFunctionTemplate(node, nameNode);
    } else {
        // this function has a registered SQLFunction -> redirect output and catch the arguments
        outputStack.addFirst(writer);
        if (node.getType() == CAST) {
            writer = new CastFunctionArguments();
        } else {
            writer = new StandardFunctionArguments();
        }
    }
}
Also used : FunctionNode(org.hibernate.hql.internal.ast.tree.FunctionNode) SQLFunction(org.hibernate.dialect.function.SQLFunction)

Aggregations

SQLFunction (org.hibernate.dialect.function.SQLFunction)2 FunctionNode (org.hibernate.hql.internal.ast.tree.FunctionNode)2 Type (org.hibernate.type.Type)1