Search in sources :

Example 1 with SelfRenderingSqmFunction

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

the class NvlCoalesceEmulation method generateSqmFunctionExpression.

@Override
protected <T> SelfRenderingSqmFunction<T> generateSqmFunctionExpression(List<? extends SqmTypedNode<?>> arguments, ReturnableType<T> impliedResultType, QueryEngine queryEngine, TypeConfiguration typeConfiguration) {
    SqmFunctionDescriptor nvl = queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder("nvl").setExactArgumentCount(2).descriptor();
    int pos = arguments.size();
    SqmExpression<?> result = (SqmExpression<?>) arguments.get(--pos);
    ReturnableType<?> type = (ReturnableType<?>) result.getNodeType();
    while (pos > 0) {
        SqmExpression<?> next = (SqmExpression<?>) arguments.get(--pos);
        result = nvl.generateSqmExpression(asList(next, result), type, queryEngine, typeConfiguration);
    }
    // noinspection unchecked
    return (SelfRenderingSqmFunction<T>) result;
}
Also used : ReturnableType(org.hibernate.query.ReturnableType) SelfRenderingSqmFunction(org.hibernate.query.sqm.function.SelfRenderingSqmFunction) SqmExpression(org.hibernate.query.sqm.tree.expression.SqmExpression) SqmFunctionDescriptor(org.hibernate.query.sqm.function.SqmFunctionDescriptor) AbstractSqmFunctionDescriptor(org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor)

Aggregations

ReturnableType (org.hibernate.query.ReturnableType)1 AbstractSqmFunctionDescriptor (org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor)1 SelfRenderingSqmFunction (org.hibernate.query.sqm.function.SelfRenderingSqmFunction)1 SqmFunctionDescriptor (org.hibernate.query.sqm.function.SqmFunctionDescriptor)1 SqmExpression (org.hibernate.query.sqm.tree.expression.SqmExpression)1