/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <blockquote><pre> * EclipseLink: employee.get("age").in(ages) * Java: ages.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </pre></blockquote> */ public Expression in(Collection theObjects) { return in(new CollectionExpression(theObjects, this)); }
public void printSQL(ExpressionSQLPrinter printer) { Object value = getLocalBase().getFieldValue(getValue(), getSession()); printer.printList((Collection)value); }
/** * INTERNAL: * Return the value for in memory comparison. * This is only valid for valueable expressions. */ public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { if (value instanceof Collection) { Collection values = (Collection)value; Vector fieldValues = new Vector(values.size()); for (Iterator iterator = values.iterator(); iterator.hasNext();) { Object value = iterator.next(); if (value instanceof Expression){ value = ((Expression)value).valueFromObject(object, session, translationRow, valueHolderPolicy, isObjectUnregistered); }else{ value = getLocalBase().getFieldValue(value, session); } fieldValues.add(value); } return fieldValues; } return getLocalBase().getFieldValue(getValue(), session); }
public void printSQL(ExpressionSQLPrinter printer) { Object value = this.value; if(this.localBase != null) { value = this.localBase.getFieldValue(value, getSession()); } printer.printList((Collection)value); }
/** * Add to list of values to be tested against. * @param value value * @return in predicate */ public In<T> value(T value){ ((Collection)((CollectionExpression)((RelationExpression)this.currentNode).getSecondChild()).getValue()).add(value); return this; }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Map alreadyDone) { super.postCopyIn(alreadyDone); if (this.value instanceof Collection) { Collection values = (Collection)this.value; Vector newValues = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(values.size()); for (Iterator iterator = values.iterator(); iterator.hasNext();) { Object val = iterator.next(); if (val instanceof Expression){ newValues.add(((Expression)val).copiedVersionFrom(alreadyDone)); } else { newValues.add(val); } } setValue(newValues); } } }
/** * INTERNAL: * Return the value for in memory comparison. * This is only valid for valueable expressions. */ public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) { if (value instanceof Collection) { Collection values = (Collection)value; Vector fieldValues = new Vector(values.size()); for (Iterator iterator = values.iterator(); iterator.hasNext();) { Object value = iterator.next(); if (value instanceof Expression){ value = ((Expression)value).valueFromObject(object, session, translationRow, valueHolderPolicy, isObjectUnregistered); }else{ value = getLocalBase().getFieldValue(value, session); } fieldValues.add(value); } return fieldValues; } return getLocalBase().getFieldValue(getValue(), session); }
RelationExpression baseIn = (RelationExpression) this.currentNode; ((InternalSelection) value).getCurrentNode().setLocalBase(baseIn.getFirstChild()); ((Collection) ((CollectionExpression) baseIn.getSecondChild()).getValue()).add(((InternalSelection) value).getCurrentNode()); } else { throw new IllegalStateException(ExceptionLocalization.buildMessage("CANNOT_ADD_CONSTANTS_TO_SUBQUERY_IN"));
public void printSQL(ExpressionSQLPrinter printer) { Object value = getLocalBase().getFieldValue(getValue(), getSession()); printer.printList((Collection)value); }
/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <blockquote><pre> * EclipseLink: employee.get("age").in(ages) * Java: ages.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </pre></blockquote> */ public Expression in(Collection theObjects) { return in(new CollectionExpression(theObjects, this)); }
/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * The collection can be a collection of constants or expressions. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <blockquote><pre> * EclipseLink: employee.get("age").in(ages) * Java: ages.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </pre></blockquote> */ public Expression notIn(Collection theObjects) { return notIn(new CollectionExpression(theObjects, this)); }
/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * The collection can be a collection of constants or expressions. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <blockquote><pre> * EclipseLink: employee.get("age").in(ages) * Java: ages.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </pre></blockquote> */ public Expression notIn(Collection theObjects) { return notIn(new CollectionExpression(theObjects, this)); }
/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <pre><blockquote> * TopLink: employee.get("age").in(agesVector) * Java: agesVector.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </blockquote></pre> */ public Expression in(Collection theObjects) { return in(new CollectionExpression(theObjects, this)); }
/** * PUBLIC: * Return an expression that checks if the receivers value is contained in the collection. * The collection can be a collection of constants or expressions. * This is equivalent to the SQL "IN" operator and Java "contains" operator. * <p>Example: * <pre><blockquote> * TopLink: employee.get("age").in(agesVector) * Java: agesVector.contains(employee.getAge()) * SQL: AGE IN (55, 18, 30) * </blockquote></pre> */ public Expression notIn(Collection theObjects) { return notIn(new CollectionExpression(theObjects, this)); }
/** * {@inheritDoc} */ @Override public void visit(CollectionExpression expression) { // Assume this is a nested array List<Expression> children = new LinkedList<Expression>(); for (org.eclipse.persistence.jpa.jpql.parser.Expression child : expression.children()) { child.accept(this); children.add(queryExpression); } queryExpression = new org.eclipse.persistence.internal.expressions.CollectionExpression(children, queryContext.getBaseExpression()); }
/** * {@inheritDoc} */ @Override public void visit(CollectionExpression expression) { // Assume this is a nested array List<Expression> children = new LinkedList<Expression>(); for (org.eclipse.persistence.jpa.jpql.parser.Expression child : expression.children()) { child.accept(this); children.add(queryExpression); } queryExpression = new org.eclipse.persistence.internal.expressions.CollectionExpression(children, queryContext.getBaseExpression()); }