use of jakarta.persistence.criteria.Expression 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;
}
use of jakarta.persistence.criteria.Expression in project eclipselink by eclipse-ee4j.
the class SubQueryImpl method in.
/**
* Apply a predicate to test whether the expression is a member
* of the argument list.
* @return predicate testing for membership
*/
@Override
public Predicate in(Expression<?>... values) {
List<Expression<?>> list = new ArrayList<>();
list.add(this);
for (Expression exp : values) {
if (!((InternalExpression) exp).isLiteral() && !((InternalExpression) exp).isParameter()) {
Object[] params = new Object[] { exp };
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("CRITERIA_NON_LITERAL_PASSED_TO_IN", params));
}
}
return new CompoundExpressionImpl(this.metamodel, this.currentNode.in(values), list, "in");
}
Aggregations