use of org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression in project eclipselink by eclipse-ee4j.
the class AbstractActualJPQLQueryFormatter method toStringSingleEncapsulated.
protected void toStringSingleEncapsulated(AbstractSingleEncapsulatedExpressionStateObject stateObject) {
if (stateObject.isDecorated()) {
toText(stateObject);
} else {
AbstractSingleEncapsulatedExpression expression = stateObject.getExpression();
// Identifier
appendIdentifier((expression != null) ? expression.getActualIdentifier() : stateObject.getIdentifier(), stateObject.getIdentifier());
// '('
if (shouldOutput(expression) || expression.hasLeftParenthesis()) {
writer.append(LEFT_PARENTHESIS);
}
if (stateObject.hasStateObject()) {
stateObject.getStateObject().accept(this);
}
// ')'
if (shouldOutput(expression) || expression.hasRightParenthesis()) {
writer.append(RIGHT_PARENTHESIS);
}
}
}
use of org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateFunctionPathExpression.
/**
* Validates the given {@link AbstractSingleEncapsulatedExpression}'s encapsulated expression if
* it is a state field path expression and makes sure it is mapping to a basic mapping. That
* means relationship field mapping is not allowed.
*
* @param expression The {@link AbstractSingleEncapsulatedExpression} to validate its encapsulated
* expression if it's a state field path expression, otherwise does nothing
* @return <code>false</code> if the encapsulated expression was validated and is invalid;
* <code>true</code> otherwise
*/
protected boolean validateFunctionPathExpression(AbstractSingleEncapsulatedExpression expression) {
boolean valid = true;
if (expression.hasEncapsulatedExpression()) {
Expression encapsulatedExpression = expression.getExpression();
// Special case for state field path expression, association field is not allowed
StateFieldPathExpression pathExpression = getStateFieldPathExpression(encapsulatedExpression);
if (pathExpression != null) {
valid = validateStateFieldPathExpression(pathExpression, PathType.BASIC_FIELD_ONLY);
} else {
encapsulatedExpression.accept(this);
}
}
return valid;
}
Aggregations