Top Description Fields Constructors Methods
org.eclipse.persistence.expressions

public Class ExpressionBuilder

extends ObjectExpression
Class Inheritance
Imports
java.io.BufferedWriter, .IOException, java.util.Map, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.QueryException, org.eclipse.persistence.history.AsOfClause, org.eclipse.persistence.internal.expressions.ExpressionJavaPrinter, .ExpressionNormalizer, .ObjectExpression, .SQLSelectStatement, org.eclipse.persistence.internal.helper.DatabaseTable, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.queries.DatabaseQuery, .ReadQuery

Purpose: Allow for instances of expression to be created. Expressions are Java object-level representations of SQL "where" clauses. The expressions attempt to mirror Java code as closely as possible.

Example:

       ExpressionBuilder employee = new ExpressionBuilder();
       employee.get("firstName").equal("Bob").and(employee.get("lastName").equal("Smith"))

       >> equivalent Java code: (employee.getFirstName().equals("Bob")) && (employee.getLastName().equals("Smith"))

       >> equivalent SQL: (F_NAME = 'Bob') AND (L_NAME = 'Smith')
See Also
Expression

Field Summary

Modifier and TypeField and Description
protected DatabaseTable
protected Class<?>
protected transient AbstractSession
protected SQLSelectStatement
protected DatabaseTable
protected boolean
protected boolean
Inherited from org.eclipse.persistence.internal.expressions.ObjectExpression:
castClassderivedExpressionsdescriptorhasBeenAliasedjoinSourceonClauseshouldUseOuterJoinshouldUseOuterJoinForMultitableInheritance

Constructor Summary

AccessConstructor and Description
public
ExpressionBuilder()

PUBLIC: Create a new ExpressionBuilder.

public
ExpressionBuilder(Class<?> queryClass)

ADVANCED: Create a new ExpressionBuilder representing instances of the argument class.

Method Summary

Modifier and TypeMethod and Description
public DatabaseTable
public int
assignTableAliasesStartingAt(int initialValue)

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.assignTableAliasesStartingAt.

INTERNAL: Assign aliases to any tables which I own.
public String
public boolean
doesNotRepresentAnObjectInTheQuery()

INTERNAL: There are cases (which we might want to eliminate?) where the expression builder doesn't actually correspond to an object to be read.

public boolean
equals(Object
the reference object with which to compare.
expression
)

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.equals.

INTERNAL: Return if the expression is equal to the other.
public DatabaseTable
public ExpressionBuilder
getBuilder()

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.getBuilder.

INTERNAL: 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 ClassDescriptor
getDescriptor()

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.getDescriptor.

INTERNAL: Only usable after the session and class have been set.
public ClassDescriptor
getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)

Overrides org.eclipse.persistence.expressions.Expression.getLeafDescriptor.

INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.
public Class<?>
getQueryClass()

INTERNAL:

public AbstractSession
public SQLSelectStatement
getStatement()

INTERNAL: Return the statement that expression is for.

public DatabaseTable
getViewTable()

INTERNAL:

public boolean
hasViewTable()

INTERNAL:

public boolean
public Expression
normalize(ExpressionNormalizer normalizer)

Overrides org.eclipse.persistence.internal.expressions.DataExpression.normalize.

INTERNAL: Normalize the expression into a printable structure.
public void
public Expression
rebuildOn(Expression newBase)

Implements abstract org.eclipse.persistence.expressions.Expression.rebuildOn.

INTERNAL: This expression is built on a different base than the one we want.
protected Expression
registerIn(Map<K, V> alreadyDone)

Overrides org.eclipse.persistence.expressions.Expression.registerIn.

INTERNAL: Override Expression.registerIn to check if the new base expression has already been provided for the clone.
public void
resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.resetPlaceHolderBuilder.

INTERNAL: Search the tree for any expressions (like SubSelectExpressions) that have been built using a builder that is not attached to the query.
public void
setQueryClass(Class<?> queryClass)

INTERNAL: Set the class which this node represents.

public void
setQueryClassAndDescriptor(Class<?> queryClass, ClassDescriptor descriptor)

INTERNAL: Set the class and descriptor which this node represents.

public void
setSession(AbstractSession session)

INTERNAL: Set the session in which we expect this expression to be translated.

public void
setStatement(SQLSelectStatement statement)

INTERNAL: Set the statement that expression is for.

public void
setViewTable(DatabaseTable theTable)

INTERNAL: This expression represents something read through a view table.

public void
setWasAdditionJoinCriteriaUsed(boolean joinCriteriaUsed)

INTERNAL: If the additional Join Criteria for the class this builder represents has been added to the statement then mark this as true.

public Expression
twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)

Overrides org.eclipse.persistence.expressions.Expression.twistedForBaseAndContext.

INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression.
public Object
valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean
true if object possibly not a clone, but is being conformed against the unit of work cache.
isObjectUnregistered
)

Overrides org.eclipse.persistence.expressions.Expression.valueFromObject.

INTERNAL: The expression builder represent the entire object, just return it.
public boolean
wasAdditionJoinCriteriaUsed()

INTERNAL: If the additional Join Criteria for the class this builder represents has been added to the statement this method will return true;

public boolean
wasQueryClassSetInternally()

INTERNAL: Returns true if TopLink set the query class as opposed to the customer.

public void
Inherited from org.eclipse.persistence.internal.expressions.ObjectExpression:
addDerivedExpressionadditionalExpressionCriteriaadditionalExpressionCriteriaMapanyOfanyOfAllowingNoneclearAliasesconvertToCastDescriptorcopyDerivedExpressionsderivedExpressionNamedderivedManualExpressionNameddoNotUseOuterJoindoUseOuterJoinexistingDerivedExpressionNamedgetgetAdditionalTablesgetAllowingNullgetCastClassgetFieldsgetFirstNonAggregateExpressionAfterExpressionBuildergetForUpdateOfFieldsgetJoinSourcegetManualQueryKeygetOnClausegetOuterJoinExpIndexgetOwnedTablesgetRelationTablegetSelectionFieldshasBeenAliasedhasDerivedExpressionsisDirectCollectionisDowncastisObjectExpressionisTreatUsedisUsingOuterJoinForMultitableInheritancejoinleftJoinnewDerivedExpressionNamednewManualDerivedExpressionNamedpostCopyInpostCopyInsetCastClasssetJoinSourcesetOnClausesetOuterJoinExpIndexsetShouldUseOuterJoinForMultitableInheritanceshouldUseOuterJoinshouldUseOuterJoinForMultitableInheritancetreattypewriteForUpdateOfFields

Field Detail

aliasedViewTableback to summary
protected DatabaseTable aliasedViewTable
queryClassback to summary
protected Class<?> queryClass
sessionback to summary
protected transient AbstractSession session
statementback to summary
protected SQLSelectStatement statement
viewTableback to summary
protected DatabaseTable viewTable
wasAdditionJoinCriteriaUsedback to summary
protected boolean wasAdditionJoinCriteriaUsed
wasQueryClassSetInternallyback to summary
protected boolean wasQueryClassSetInternally

Constructor Detail

ExpressionBuilderback to summary
public ExpressionBuilder()

PUBLIC: Create a new ExpressionBuilder.

ExpressionBuilderback to summary
public ExpressionBuilder(Class<?> queryClass)

ADVANCED: Create a new ExpressionBuilder representing instances of the argument class. This can be used for the purpose of parallel expressions. This is a type of query that searches on the relationship between to un-related objects.

Method Detail

aliasForTableback to summary
public DatabaseTable aliasForTable(DatabaseTable table)

Overrides org.eclipse.persistence.internal.expressions.DataExpression.aliasForTable.

INTERNAL: Find the alias for a given table. Handle the special case where we are bogus and it should be aliased against our derived tables instead.

Annotations
@Override
assignTableAliasesStartingAtback to summary
public int assignTableAliasesStartingAt(int initialValue)

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.assignTableAliasesStartingAt.

INTERNAL: Assign aliases to any tables which I own. Start with t(initialValue), and return the new value of the counter , i.e. if initialValue is one and I have tables ADDRESS and EMPLOYEE I will assign them t1 and t2 respectively, and return 3.

Annotations
@Override
descriptionOfNodeTypeback to summary
public String descriptionOfNodeType()

Overrides org.eclipse.persistence.expressions.Expression.descriptionOfNodeType.

INTERNAL: Used for debug printing.

Annotations
@Override
doesNotRepresentAnObjectInTheQueryback to summary
public boolean doesNotRepresentAnObjectInTheQuery()

INTERNAL: There are cases (which we might want to eliminate?) where the expression builder doesn't actually correspond to an object to be read. Mostly this is the case where it's a data query in terms of tables, and the builder is only there to provide a base. It might be better to make tables able to serve as their own base, but it's very nice to have a known unique, shared base. In the meantime, this is a special case to make sure the builder doesn't get tables assigned.

equalsback to summary
public boolean equals(Object expression)

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.equals.

INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.

Parameters
expression:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAliasedViewTableback to summary
public DatabaseTable getAliasedViewTable()

INTERNAL:

getBuilderback to summary
public ExpressionBuilder getBuilder()

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.getBuilder.

INTERNAL: 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)

Annotations
@Override
getDescriptorback to summary
public ClassDescriptor getDescriptor()

Overrides org.eclipse.persistence.internal.expressions.ObjectExpression.getDescriptor.

INTERNAL: Only usable after the session and class have been set. Return the descriptor for the class this node represents.

Annotations
@Override
getLeafDescriptorback to summary
public ClassDescriptor getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)

Overrides org.eclipse.persistence.expressions.Expression.getLeafDescriptor.

INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.

Annotations
@Override
getQueryClassback to summary
public Class<?> getQueryClass()

INTERNAL:

getSessionback to summary
public AbstractSession getSession()

Overrides org.eclipse.persistence.expressions.Expression.getSession.

INTERNAL:

Annotations
@Override
getStatementback to summary
public SQLSelectStatement getStatement()

INTERNAL: Return the statement that expression is for. This is used for the context in subselects.

getViewTableback to summary
public DatabaseTable getViewTable()

INTERNAL:

hasViewTableback to summary
public boolean hasViewTable()

INTERNAL:

isExpressionBuilderback to summary
public boolean isExpressionBuilder()

Overrides org.eclipse.persistence.expressions.Expression.isExpressionBuilder.

INTERNAL:

Annotations
@Override
normalizeback to summary
public Expression normalize(ExpressionNormalizer normalizer)

Overrides org.eclipse.persistence.internal.expressions.DataExpression.normalize.

INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.

Annotations
@Override
printJavaback to summary
public void printJava(ExpressionJavaPrinter printer)

Overrides org.eclipse.persistence.expressions.Expression.printJava.

INTERNAL: Print java

Annotations
@Override
rebuildOnback to summary
public Expression rebuildOn(Expression newBase)

Implements abstract org.eclipse.persistence.expressions.Expression.rebuildOn.

INTERNAL: This expression is built on a different base than the one we want. Rebuild it and return the root of the new tree This assumes that the original expression has only a single builder.

Annotations
@Override
registerInback to summary
protected Expression registerIn(Map<K, V> alreadyDone)

Overrides org.eclipse.persistence.expressions.Expression.registerIn.

INTERNAL: Override Expression.registerIn to check if the new base expression has already been provided for the clone.

Annotations
@Override
See Also
org.eclipse.persistence.expressions.Expression#cloneUsing(Expression)
resetPlaceHolderBuilderback to summary
public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.resetPlaceHolderBuilder.

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.

Annotations
@Override
setQueryClassback to summary
public void setQueryClass(Class<?> queryClass)

INTERNAL: Set the class which this node represents.

setQueryClassAndDescriptorback to summary
public void setQueryClassAndDescriptor(Class<?> queryClass, ClassDescriptor descriptor)

INTERNAL: Set the class and descriptor which this node represents.

setSessionback to summary
public void setSession(AbstractSession session)

INTERNAL: Set the session in which we expect this expression to be translated. Stored session shall always be root session.

setStatementback to summary
public void setStatement(SQLSelectStatement statement)

INTERNAL: Set the statement that expression is for. This is used for the context in subselects.

setViewTableback to summary
public void setViewTable(DatabaseTable theTable)

INTERNAL: This expression represents something read through a view table.

setWasAdditionJoinCriteriaUsedback to summary
public void setWasAdditionJoinCriteriaUsed(boolean joinCriteriaUsed)

INTERNAL: If the additional Join Criteria for the class this builder represents has been added to the statement then mark this as true. This will prevent TopLink from adding it again at normalization

twistedForBaseAndContextback to summary
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)

Overrides org.eclipse.persistence.expressions.Expression.twistedForBaseAndContext.

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.

Annotations
@Override
valueFromObjectback to summary
public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered)

Overrides org.eclipse.persistence.expressions.Expression.valueFromObject.

INTERNAL: The expression builder represent the entire object, just return it.

Parameters
isObjectUnregistered:boolean

Doc from org.eclipse.persistence.expressions.Expression.valueFromObject.

true if object possibly not a clone, but is being conformed against the unit of work cache.

Annotations
@Override
wasAdditionJoinCriteriaUsedback to summary
public boolean wasAdditionJoinCriteriaUsed()

INTERNAL: If the additional Join Criteria for the class this builder represents has been added to the statement this method will return true;

wasQueryClassSetInternallyback to summary
public boolean wasQueryClassSetInternally()

INTERNAL: Returns true if TopLink set the query class as opposed to the customer. This is important in determining if this Expression should be treated as a parallel expression during normalization

writeDescriptionOnback to summary
public void writeDescriptionOn(BufferedWriter writer) throws IOException

Overrides org.eclipse.persistence.expressions.Expression.writeDescriptionOn.

INTERNAL: For debug printing purposes.

Annotations
@Override