use of org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression in project eclipselink by eclipse-ee4j.
the class AbstractActualJPQLQueryFormatter method visit.
@Override
public void visit(CoalesceExpressionStateObject stateObject) {
if (stateObject.isDecorated()) {
toText(stateObject);
} else {
CoalesceExpression expression = stateObject.getExpression();
// 'COALESCE'
appendIdentifier((expression != null) ? expression.getActualIdentifier() : COALESCE, COALESCE);
// '('
if (shouldOutput(expression) || expression.hasLeftParenthesis()) {
writer.append(LEFT_PARENTHESIS);
} else if (expression.hasSpaceAfterIdentifier()) {
writer.append(SPACE);
}
toStringChildren(stateObject, true);
// ')'
if (shouldOutput(expression) || expression.hasRightParenthesis()) {
writer.append(RIGHT_PARENTHESIS);
}
}
}
use of org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression in project eclipselink by eclipse-ee4j.
the class ReportItemBuilder method visit.
@Override
public void visit(CoalesceExpression expression) {
Expression queryExpression = queryContext.buildExpression(expression, type);
addAttribute("Coalesce", queryExpression);
}
use of org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(CoalesceExpression expression) {
List<Expression> expressions = new ArrayList<>();
List<Class<?>> types = new LinkedList<>();
// cache the type of the expression so untyped children have a default type
Class<?> coalesceType = type[0];
// Create the Expression for each scalar expression
for (org.eclipse.persistence.jpa.jpql.parser.Expression child : expression.getExpression().children()) {
child.accept(this);
expressions.add(queryExpression);
// get the expression type parsed from the child expression
Class<?> childType = type[0];
// This is to help provide a valid type for null parameter when binding JDBC parameter types
if (queryExpression.isParameterExpression()) {
ParameterExpression paramExpression = (ParameterExpression) queryExpression;
if (paramExpression.getType() == null || paramExpression.getType().equals(Object.class)) {
paramExpression.setType(coalesceType);
childType = coalesceType;
}
}
types.add(childType);
}
// Create the COALESCE expression
queryExpression = queryContext.getBaseExpression();
queryExpression = queryExpression.coalesce(expressions);
// Set the expression type
type[0] = queryContext.typeResolver().compareCollectionEquivalentTypes(types);
}
Aggregations