Search in sources :

Example 1 with SubSelectExpression

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

the class DescriptorQueryManager method updatePropertyParameterExpression.

/**
 * INTERNAL:
 * This method will walk the given expression and mark any parameter
 * expressions as property expressions. This is done when additional
 * criteria has been specified and parameter values must be resolved
 * through session properties.
 *
 * @see #postInitialize
 */
protected void updatePropertyParameterExpression(Expression exp) {
    if (exp.isCompoundExpression()) {
        updatePropertyParameterExpression(((CompoundExpression) exp).getFirstChild());
        updatePropertyParameterExpression(((CompoundExpression) exp).getSecondChild());
    } else if (exp.isFunctionExpression()) {
        for (Expression e : ((FunctionExpression) exp).getChildren()) {
            updatePropertyParameterExpression(e);
        }
    } else if (exp.isSubSelectExpression()) {
        ReportQuery subSelectQuery = ((SubSelectExpression) exp).getSubQuery();
        for (ReportItem item : subSelectQuery.getItems()) {
            updatePropertyParameterExpression(item.getAttributeExpression());
        }
    }
    if (exp.isParameterExpression()) {
        ((ParameterExpression) exp).setIsProperty(true);
    }
}
Also used : SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) ParameterExpression(org.eclipse.persistence.internal.expressions.ParameterExpression) CompoundExpression(org.eclipse.persistence.internal.expressions.CompoundExpression) FunctionExpression(org.eclipse.persistence.internal.expressions.FunctionExpression) Expression(org.eclipse.persistence.expressions.Expression) ReportQuery(org.eclipse.persistence.queries.ReportQuery) ParameterExpression(org.eclipse.persistence.internal.expressions.ParameterExpression) ReportItem(org.eclipse.persistence.internal.queries.ReportItem)

Example 2 with SubSelectExpression

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

the class CriteriaBuilderImpl method not.

/**
 * Create a negation of the given restriction.
 *
 * @param restriction
 *            restriction expression
 * @return not predicate
 */
@Override
public Predicate not(Expression<Boolean> restriction) {
    if (((InternalExpression) restriction).isPredicate()) {
        return ((Predicate) restriction).not();
    }
    org.eclipse.persistence.expressions.Expression parentNode = null;
    List<Expression<?>> compoundExpressions = null;
    String name = "not";
    if (((InternalExpression) restriction).isCompoundExpression() && ((CompoundExpressionImpl) restriction).getOperation().equals("exists")) {
        FunctionExpression exp = (FunctionExpression) ((InternalSelection) restriction).getCurrentNode();
        SubSelectExpression sub = (SubSelectExpression) exp.getChildren().get(0);
        parentNode = ExpressionOperator.getOperator(ExpressionOperator.NotExists).expressionFor(sub);
        name = "notExists";
        compoundExpressions = ((CompoundExpressionImpl) restriction).getChildExpressions();
    } else {
        parentNode = ((InternalSelection) restriction).getCurrentNode().not();
        compoundExpressions = buildList(restriction);
    }
    CompoundExpressionImpl expr = new CompoundExpressionImpl(this.metamodel, parentNode, compoundExpressions, name);
    expr.setIsNegated(true);
    return expr;
}
Also used : ArgumentListFunctionExpression(org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression) FunctionExpression(org.eclipse.persistence.internal.expressions.FunctionExpression) SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) ParameterExpression(jakarta.persistence.criteria.ParameterExpression) Expression(jakarta.persistence.criteria.Expression) ArgumentListFunctionExpression(org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression) SubSelectExpression(org.eclipse.persistence.internal.expressions.SubSelectExpression) FunctionExpression(org.eclipse.persistence.internal.expressions.FunctionExpression) ConstantExpression(org.eclipse.persistence.internal.expressions.ConstantExpression) Predicate(jakarta.persistence.criteria.Predicate)

Aggregations

FunctionExpression (org.eclipse.persistence.internal.expressions.FunctionExpression)2 SubSelectExpression (org.eclipse.persistence.internal.expressions.SubSelectExpression)2 Expression (jakarta.persistence.criteria.Expression)1 ParameterExpression (jakarta.persistence.criteria.ParameterExpression)1 Predicate (jakarta.persistence.criteria.Predicate)1 Expression (org.eclipse.persistence.expressions.Expression)1 ArgumentListFunctionExpression (org.eclipse.persistence.internal.expressions.ArgumentListFunctionExpression)1 CompoundExpression (org.eclipse.persistence.internal.expressions.CompoundExpression)1 ConstantExpression (org.eclipse.persistence.internal.expressions.ConstantExpression)1 ParameterExpression (org.eclipse.persistence.internal.expressions.ParameterExpression)1 ReportItem (org.eclipse.persistence.internal.queries.ReportItem)1 ReportQuery (org.eclipse.persistence.queries.ReportQuery)1