Search in sources :

Example 1 with BaseExpression

use of org.eclipse.persistence.internal.expressions.BaseExpression in project eclipselink by eclipse-ee4j.

the class JoinedAttributeManager method addExpressionAndBaseToGroupedList.

/**
 * adds expression and its base expressions recursively to the expressionList in groups, so that an expression is never listed before
 * its base expression
 */
protected Expression addExpressionAndBaseToGroupedList(Expression expression, List expressionlist, Expression lastJoinedAttributeBaseExpression) {
    if (!expressionlist.contains(expression)) {
        int baseExpressionIndex = -1;
        // better than using instanceof BaseExpression.  If its not an objectExpression, it will get an exception in prepare anyway
        boolean sameBase = false;
        if ((expression.isObjectExpression())) {
            Expression baseExpression = ((BaseExpression) expression).getBaseExpression();
            // filter out aggregate expressions between this and the next node.
            while (!baseExpression.isExpressionBuilder() && ((QueryKeyExpression) baseExpression).getMapping().isAggregateMapping()) {
                baseExpression = ((BaseExpression) baseExpression).getBaseExpression();
            }
            if (baseExpression != null && !baseExpression.isExpressionBuilder()) {
                addExpressionAndBaseToGroupedList(baseExpression, expressionlist, lastJoinedAttributeBaseExpression);
                // EL bug 307497
                if (baseExpression != lastJoinedAttributeBaseExpression) {
                    baseExpressionIndex = getJoinedAttributeExpressions().indexOf(baseExpression);
                } else {
                    sameBase = true;
                }
            }
        }
        // EL bug 307497
        if (baseExpressionIndex == -1) {
            expressionlist.add(expression);
            if (!sameBase) {
                lastJoinedAttributeBaseExpression = expression;
            }
        } else {
            // Add attributeExpression at baseExpressionIndex + 1.
            expressionlist.add(baseExpressionIndex + 1, expression);
        }
    }
    return lastJoinedAttributeBaseExpression;
}
Also used : BaseExpression(org.eclipse.persistence.internal.expressions.BaseExpression) BaseExpression(org.eclipse.persistence.internal.expressions.BaseExpression) QueryKeyExpression(org.eclipse.persistence.internal.expressions.QueryKeyExpression) ObjectExpression(org.eclipse.persistence.internal.expressions.ObjectExpression) Expression(org.eclipse.persistence.expressions.Expression) QueryKeyExpression(org.eclipse.persistence.internal.expressions.QueryKeyExpression)

Aggregations

Expression (org.eclipse.persistence.expressions.Expression)1 BaseExpression (org.eclipse.persistence.internal.expressions.BaseExpression)1 ObjectExpression (org.eclipse.persistence.internal.expressions.ObjectExpression)1 QueryKeyExpression (org.eclipse.persistence.internal.expressions.QueryKeyExpression)1