Search in sources :

Example 1 with AbstractSingleEncapsulatedExpression

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);
        }
    }
}
Also used : AbstractSingleEncapsulatedExpression(org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression)

Example 2 with AbstractSingleEncapsulatedExpression

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;
}
Also used : ArithmeticExpression(org.eclipse.persistence.jpa.jpql.parser.ArithmeticExpression) TrimExpression(org.eclipse.persistence.jpa.jpql.parser.TrimExpression) AbsExpression(org.eclipse.persistence.jpa.jpql.parser.AbsExpression) CoalesceExpression(org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression) ConcatExpression(org.eclipse.persistence.jpa.jpql.parser.ConcatExpression) SubstringExpression(org.eclipse.persistence.jpa.jpql.parser.SubstringExpression) SizeExpression(org.eclipse.persistence.jpa.jpql.parser.SizeExpression) Expression(org.eclipse.persistence.jpa.jpql.parser.Expression) SubExpression(org.eclipse.persistence.jpa.jpql.parser.SubExpression) AbstractSingleEncapsulatedExpression(org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression) AndExpression(org.eclipse.persistence.jpa.jpql.parser.AndExpression) JPQLExpression(org.eclipse.persistence.jpa.jpql.parser.JPQLExpression) IndexExpression(org.eclipse.persistence.jpa.jpql.parser.IndexExpression) StateFieldPathExpression(org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression) UpperExpression(org.eclipse.persistence.jpa.jpql.parser.UpperExpression) ExistsExpression(org.eclipse.persistence.jpa.jpql.parser.ExistsExpression) KeyExpression(org.eclipse.persistence.jpa.jpql.parser.KeyExpression) AllOrAnyExpression(org.eclipse.persistence.jpa.jpql.parser.AllOrAnyExpression) ModExpression(org.eclipse.persistence.jpa.jpql.parser.ModExpression) LikeExpression(org.eclipse.persistence.jpa.jpql.parser.LikeExpression) CaseExpression(org.eclipse.persistence.jpa.jpql.parser.CaseExpression) LengthExpression(org.eclipse.persistence.jpa.jpql.parser.LengthExpression) MultiplicationExpression(org.eclipse.persistence.jpa.jpql.parser.MultiplicationExpression) UnknownExpression(org.eclipse.persistence.jpa.jpql.parser.UnknownExpression) NullComparisonExpression(org.eclipse.persistence.jpa.jpql.parser.NullComparisonExpression) ValueExpression(org.eclipse.persistence.jpa.jpql.parser.ValueExpression) ComparisonExpression(org.eclipse.persistence.jpa.jpql.parser.ComparisonExpression) InExpression(org.eclipse.persistence.jpa.jpql.parser.InExpression) NotExpression(org.eclipse.persistence.jpa.jpql.parser.NotExpression) BadExpression(org.eclipse.persistence.jpa.jpql.parser.BadExpression) BetweenExpression(org.eclipse.persistence.jpa.jpql.parser.BetweenExpression) CompoundExpression(org.eclipse.persistence.jpa.jpql.parser.CompoundExpression) SqrtExpression(org.eclipse.persistence.jpa.jpql.parser.SqrtExpression) FunctionExpression(org.eclipse.persistence.jpa.jpql.parser.FunctionExpression) CollectionMemberExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionMemberExpression) NullExpression(org.eclipse.persistence.jpa.jpql.parser.NullExpression) ConstructorExpression(org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression) NullIfExpression(org.eclipse.persistence.jpa.jpql.parser.NullIfExpression) CollectionValuedPathExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression) LocateExpression(org.eclipse.persistence.jpa.jpql.parser.LocateExpression) AdditionExpression(org.eclipse.persistence.jpa.jpql.parser.AdditionExpression) ObjectExpression(org.eclipse.persistence.jpa.jpql.parser.ObjectExpression) CollectionExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionExpression) LowerExpression(org.eclipse.persistence.jpa.jpql.parser.LowerExpression) OrExpression(org.eclipse.persistence.jpa.jpql.parser.OrExpression) TreatExpression(org.eclipse.persistence.jpa.jpql.parser.TreatExpression) TypeExpression(org.eclipse.persistence.jpa.jpql.parser.TypeExpression) EmptyCollectionComparisonExpression(org.eclipse.persistence.jpa.jpql.parser.EmptyCollectionComparisonExpression) SubtractionExpression(org.eclipse.persistence.jpa.jpql.parser.SubtractionExpression) EntryExpression(org.eclipse.persistence.jpa.jpql.parser.EntryExpression) DivisionExpression(org.eclipse.persistence.jpa.jpql.parser.DivisionExpression) KeywordExpression(org.eclipse.persistence.jpa.jpql.parser.KeywordExpression) StateFieldPathExpression(org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression)

Aggregations

AbstractSingleEncapsulatedExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression)2 AbsExpression (org.eclipse.persistence.jpa.jpql.parser.AbsExpression)1 AdditionExpression (org.eclipse.persistence.jpa.jpql.parser.AdditionExpression)1 AllOrAnyExpression (org.eclipse.persistence.jpa.jpql.parser.AllOrAnyExpression)1 AndExpression (org.eclipse.persistence.jpa.jpql.parser.AndExpression)1 ArithmeticExpression (org.eclipse.persistence.jpa.jpql.parser.ArithmeticExpression)1 BadExpression (org.eclipse.persistence.jpa.jpql.parser.BadExpression)1 BetweenExpression (org.eclipse.persistence.jpa.jpql.parser.BetweenExpression)1 CaseExpression (org.eclipse.persistence.jpa.jpql.parser.CaseExpression)1 CoalesceExpression (org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression)1 CollectionExpression (org.eclipse.persistence.jpa.jpql.parser.CollectionExpression)1 CollectionMemberExpression (org.eclipse.persistence.jpa.jpql.parser.CollectionMemberExpression)1 CollectionValuedPathExpression (org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression)1 ComparisonExpression (org.eclipse.persistence.jpa.jpql.parser.ComparisonExpression)1 CompoundExpression (org.eclipse.persistence.jpa.jpql.parser.CompoundExpression)1 ConcatExpression (org.eclipse.persistence.jpa.jpql.parser.ConcatExpression)1 ConstructorExpression (org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression)1 DivisionExpression (org.eclipse.persistence.jpa.jpql.parser.DivisionExpression)1 EmptyCollectionComparisonExpression (org.eclipse.persistence.jpa.jpql.parser.EmptyCollectionComparisonExpression)1 EntryExpression (org.eclipse.persistence.jpa.jpql.parser.EntryExpression)1