/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } ConstantExpression expression = (ConstantExpression) object; return ((getValue() == expression.getValue()) || ((getValue() != null) && getValue().equals(expression.getValue()))); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { Object value = getLocalBase().getFieldValue(getValue(), getSession()); if(value == null) { printer.printNull(this); } else { printer.printPrimitive(value); } }
/** * INTERNAL: * Create an expression node. */ public static Expression fromConstant(Object value, Expression base) { return new ConstantExpression(value, base); }
/** * 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 result = (ConstantExpression)clone(); result.setLocalBase(getLocalBase().rebuildOn(newBase)); return result; }
foreignKeyJoin = (new ConstantExpression(0, base)).equal(new ConstantExpression(0, base)); }else{ int size = this.mechanism.sourceKeyFields.size();
value = ((FieldExpression)expression).getField(); } else if (expression.isConstantExpression()) { value = ((ConstantExpression)expression).getValue(); if (((ConstantExpression)expression).getLocalBase() != null) { value = ((ConstantExpression)expression).getLocalBase().getFieldValue(value, query.getSession());
/** * INTERNAL: * Search the tree for any expressions (like SubSelectExpressions) that have been * built using a builder that is not attached to the query. This happens in case of an Exists * call using a new ExpressionBuilder(). This builder needs to be replaced with one from the query. */ public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder){ getLocalBase().resetPlaceHolderBuilder(queryBuilder); }
public void setLocalBase(Expression e) { super.setLocalBase(e); if (value instanceof Collection) { Collection values = (Collection)value; for (Iterator iterator = values.iterator(); iterator.hasNext();) { Object val = iterator.next(); if (val instanceof Expression){ ((Expression)val).setLocalBase(e); } } } }
/** * INTERNAL: * Append the constant value into the printer */ public void writeFields(ExpressionSQLPrinter printer, Vector newFields, SQLSelectStatement statement) { if (printer.getPlatform().isDynamicSQLRequiredForFunctions()) { printer.getCall().setUsesBinding(false); } //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } // This field is a constant value, so any name can be used. newFields.addElement(new DatabaseField("*")); printSQL(printer); } }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Map alreadyDone) { super.postCopyIn(alreadyDone); if (value instanceof Collection) { Collection values = (Collection)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); } } value = newValues; } } }
/** * 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) { return (Expression)this.clone(); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { Object value = this.value; if(this.localBase != null) { value = this.localBase.getFieldValue(value, getSession()); } if(value == null) { printer.printNull(this); } else { printer.printPrimitive(value); } }
foreignKeyJoin = (new ConstantExpression(0, base)).equal(new ConstantExpression(0, base)); }else{ int size = this.mechanism.sourceKeyFields.size();
/** * 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 result = (ConstantExpression)clone(); result.setLocalBase(getLocalBase().rebuildOn(newBase)); return result; }
/** * Return the expression builder which is the ultimate base of this expression, or * null if there isn't one (shouldn't happen if we start from a root) */ public ExpressionBuilder getBuilder() { return getLocalBase().getBuilder(); }
public void setLocalBase(Expression e) { super.setLocalBase(e); if (this.value instanceof Collection) { Collection values = (Collection)this.value; for (Iterator iterator = values.iterator(); iterator.hasNext();) { Object val = iterator.next(); if (val instanceof Expression){ ((Expression)val).setLocalBase(e); } } } }
/** * INTERNAL: * Append the constant value into the printer */ @Override public void writeFields(ExpressionSQLPrinter printer, Vector newFields, SQLSelectStatement statement) { if (printer.getPlatform().isDynamicSQLRequiredForFunctions()) { printer.getCall().setUsesBinding(false); } //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } // This field is a constant value, so any name can be used. newFields.addElement(new DatabaseField("*")); printSQL(printer); } }
/** * INTERNAL: * Used for cloning. */ protected void postCopyIn(Map alreadyDone) { super.postCopyIn(alreadyDone); if (value instanceof Collection) { Collection values = (Collection)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); } } value = newValues; } } }
/** * 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 result = (ConstantExpression)clone(); Expression localBase = null; if(this.localBase != null) { localBase = this.localBase.rebuildOn(newBase); } result.setLocalBase(localBase); return result; }
/** * INTERNAL: * Return if the expression is equal to the other. * This is used to allow dynamic expression's SQL to be cached. */ public boolean equals(Object object) { if (this == object) { return true; } if (!super.equals(object)) { return false; } ConstantExpression expression = (ConstantExpression) object; return ((getValue() == expression.getValue()) || ((getValue() != null) && getValue().equals(expression.getValue()))); }