/** * INTERNAL: */ public void initializePlatformOperator(DatabasePlatform platform) { if (getOperator().isComplete()) { platformOperator = getOperator(); return; } platformOperator = platform.getOperator(getOperator().getSelector()); if (platformOperator == null) { throw QueryException.invalidOperator(getOperator().toString()); } }
/** * INTERNAL: * Compute a consistent hash-code for the expression. * This is used to allow dynamic expression's SQL to be cached. */ public int computeHashCode() { int hashCode = super.computeHashCode(); if (getOperator() != null) { hashCode = hashCode + getOperator().hashCode(); } List children = getChildren(); int size = children.size(); for (int index = 0; index < size; index++) { hashCode = hashCode + children.get(index).hashCode(); } return hashCode; }
/** * INTERNAL: * Set the fields, if any are aggregate selects then record this so that the distinct is not printed through anyOfs. */ public void setFields(Vector fields) { for (Enumeration fieldsEnum = fields.elements(); fieldsEnum.hasMoreElements();) { Object fieldOrExpression = fieldsEnum.nextElement(); if (fieldOrExpression instanceof FunctionExpression) { if (((FunctionExpression)fieldOrExpression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); break; } } } this.fields = fields; }
if ((getOperator() != expression.getOperator()) && ((getOperator() == null) || (!getOperator().equals(expression.getOperator())))) { return false;
/** * INTERNAL: adds an expression to the fields. set a flag if the expression * is for and aggregate function. */ public void addField(Expression expression) { if (expression instanceof FunctionExpression) { if (((FunctionExpression)expression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); } } getFields().add(expression); }
/** * INTERNAL: * Set the fields, if any are aggregate selects then record this so that the distinct is not printed through anyOfs. */ public void setFields(Vector fields) { for (Object fieldOrExpression : fields) { if (fieldOrExpression instanceof FunctionExpression) { if (((FunctionExpression)fieldOrExpression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); break; } } } this.fields = fields; }
/** * INTERNAL: adds an expression to the fields. set a flag if the expression * is for and aggregate function. */ public void addField(Expression expression) { if (expression instanceof FunctionExpression) { if (((FunctionExpression)expression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); } } getFields().add(expression); }
/** * INTERNAL: adds an expression to the fields. set a flag if the expression * is for and aggregate function. */ public void addField(Expression expression) { if (expression instanceof FunctionExpression) { if (((FunctionExpression)expression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); } } getFields().addElement(expression); }
/** * INTERNAL: * Set the fields, if any are aggregate selects then record this so that the distinct is not printed through anyOfs. */ public void setFields(Vector fields) { for (Object fieldOrExpression : fields) { if (fieldOrExpression instanceof FunctionExpression) { if (((FunctionExpression)fieldOrExpression).getOperator().isAggregateOperator()) { setIsAggregateSelect(true); break; } } } this.fields = fields; }
if ((this.operator != expression.getOperator()) && ((this.operator == null) || (!this.operator.equals(expression.getOperator())))) { return false;
if ((this.operator != expression.getOperator()) && ((this.operator == null) || (!this.operator.equals(expression.getOperator())))) { return false;
/** * INTERNAL: * Rebuild myself against the base, with the values of parameters supplied by the context * expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) * into part of some larger expression. You normally would not call this directly, instead calling twist * See the comment there for more details" */ public Expression twistedForBaseAndContext(Expression newBase, Expression context) { if (this.children.isEmpty()) { return (Expression)clone(); } Vector newChildren = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(this.children.size()); // For functions the base is the first child, we only want the arguments so start at the second. for (int index = 1; index < this.children.size(); index++) { newChildren.addElement(((Expression)children.elementAt(index)).twistedForBaseAndContext(newBase, context)); } // Aply the function to the twisted old base. Expression oldBase = (Expression)this.children.elementAt(0); return oldBase.twistedForBaseAndContext(newBase, context).performOperator(getOperator(), newChildren); }
baseVector.addElement(baseObject); } else { baseVector.addElement(getOperator().applyFunction(baseObject, arguments)); return null; } else { return getOperator().applyFunction(baseValue, arguments);
/** * INTERNAL: * Return if the represents an object comparison. */ protected boolean isObjectComparison() { if (this.children.size() != 1) { return false; } int selector = getOperator().getSelector(); if ((selector != ExpressionOperator.IsNull) && (selector != ExpressionOperator.NotNull)) { return false; } Expression base = getBaseExpression(); return (base.isObjectExpression() && (!((ObjectExpression)base).isAttribute())); }
/** * INTERNAL: * This expression is built on a different base than the one we want. Rebuild it and * return the root of the new tree */ public Expression rebuildOn(Expression newBase) { Expression newLocalBase = getBaseExpression().rebuildOn(newBase); Vector newChildren = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(this.children.size()); for (int i = 1; i < this.children.size(); i++) {// Skip the first one, since it's also the base newChildren.addElement(((Expression)children.elementAt(i)).rebuildOn(newBase)); } newLocalBase.setSelectIfOrderedBy(getBaseExpression().selectIfOrderedBy()); FunctionExpression rebuilt = (FunctionExpression) newLocalBase.performOperator(getOperator(), newChildren); rebuilt.setResultType(this.getResultType()); //copy over result type. return rebuilt; }
/** * Append the order by expression to the sort row. */ protected void appendExpressionToSortRow(Expression expression, AbstractRecord row, DatabaseQuery query) { if (expression.isFunctionExpression()) { FunctionExpression function = (FunctionExpression)expression; if (function.getOperator().getSelector() == ExpressionOperator.Ascending) { Object field = extractValueFromExpression(function.getChildren().get(0), query); row.put(field, 1); } else if (function.getOperator().getSelector() == ExpressionOperator.Descending) { Object field = extractValueFromExpression(function.getChildren().get(0), query); row.put(field, -1); } else { throw new EISException("Query too complex for Mongo translation, order by [" + expression + "] not supported in query: " + query); } } else { Object field = extractValueFromExpression(expression, query); row.put(field, 1); } }
if (getOperator().getSelector() == ExpressionOperator.NotNull) { foreignKeyJoin = foreignKeyJoin.not();
int selector = getOperator().getSelector(); if (selector != ExpressionOperator.Maximum && selector != ExpressionOperator.Minimum) { field.setType(null);
String queryKeyName = expression.getBaseExpression().getName(); if (expression.getOperator().getSelector() == ExpressionOperator.Descending) { method.addLine(mappingName + ".addDescendingOrdering(\"" + queryKeyName + "\");"); } else {
private void prepareObjectAttributeCount(ExpressionNormalizer normalizer) { Expression baseExp = this.getBaseExpression(); boolean distinctUsed = false; if (baseExp.isFunctionExpression() && (((FunctionExpression) baseExp).getOperator().getSelector() == ExpressionOperator.Distinct)) { distinctUsed = true; baseExp = ((FunctionExpression) baseExp).getBaseExpression();