use of com.blazebit.persistence.spi.JpqlFunctionProcessor in project blaze-persistence by Blazebit.
the class SelectManager method addJpqlFunctionProcessor.
private void addJpqlFunctionProcessor(Expression expr, int index) {
if (expr instanceof FunctionExpression) {
String functionName = ((FunctionExpression) expr).getFunctionName().toLowerCase();
JpqlFunction jpqlFunction = mainQuery.cbf.getRegisteredFunctions().get(functionName);
if (jpqlFunction instanceof JpqlFunctionProcessor<?>) {
jpqlFunctionProcessors.put(index, (JpqlFunctionProcessor<?>) jpqlFunction);
if ("to_multiset".equals(functionName)) {
Subquery subquery = ((SubqueryExpression) ((FunctionExpression) expr).getExpressions().get(0)).getSubquery();
if (subquery instanceof SubqueryInternalBuilder<?>) {
SubqueryInternalBuilder<?> subqueryInternalBuilder = (SubqueryInternalBuilder<?>) subquery;
jpqlFunctionProcessors.put(index, new NestedToMultisetJpqlFunctionProcessor((JpqlFunctionProcessor<?>) jpqlFunction, subqueryInternalBuilder.getJpqlFunctionProcessors(), subqueryInternalBuilder.getSelectExpressions()));
}
}
}
} else if (expr instanceof SubqueryExpression) {
Subquery subquery = ((SubqueryExpression) expr).getSubquery();
if (subquery instanceof SubqueryInternalBuilder<?>) {
SubqueryInternalBuilder<?> subqueryInternalBuilder = (SubqueryInternalBuilder<?>) subquery;
if (!subqueryInternalBuilder.getJpqlFunctionProcessors().isEmpty()) {
jpqlFunctionProcessors.put(index, subqueryInternalBuilder.getJpqlFunctionProcessors().get(0));
}
}
}
}
Aggregations