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;
}
Aggregations