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

public abstract Class ObjectExpression

extends DataExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.expressions.QueryKeyExpression, org.eclipse.persistence.expressions.ExpressionBuilder
Imports
java.util.ArrayList, .HashMap, .Iterator, .List, .Map, .Vector, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.QueryException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, .Helper, .NonSynchronizedVector, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.mappings.querykeys.ForeignReferenceQueryKey, org.eclipse.persistence.queries.ObjectLevelReadQuery, .ReadQuery

Superclass for any object type expressions.

Field Summary

Modifier and TypeField and Description
protected Class<?>
castClass

Allow an expression node to be cast to a subclass or implementation class.

public List<Expression>
protected transient ClassDescriptor
protected boolean
hasBeenAliased

Allow hasBeenAliased to be marked independently from the existence of the tableAliases collection.

protected Expression
joinSource

Defines that this expression has been joined to the source expression.

protected Expression
onClause

Allow for an ON clause to be specified on a join condition.

private Integer
outerJoinExpIndex

Used to track the index of the OuterJoinExpressionHolder that might be associated to this expression

protected boolean
shouldUseOuterJoin

Is this query key to be resolved using an outer join or not.

protected boolean
shouldUseOuterJoinForMultitableInheritance

indicates whether subclasses should be joined

Inherited from org.eclipse.persistence.internal.expressions.DataExpression:
asOfClausederivedFieldsderivedTableshasBeenNormalizedtableAliases

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addDerivedExpression(Expression addThis)

INTERNAL: Add the expression as a derived child of this expression.

public Expression
additionalExpressionCriteria()

INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.

public Map<K, V>
additionalExpressionCriteriaMap()

INTERNAL: Used in case outer joins should be printed in FROM clause.

public Expression
anyOf(String attributeName, boolean
indicates whether a new expression should be created.
shouldJoinBeIndependent
)

Overrides org.eclipse.persistence.expressions.Expression.anyOf.

PUBLIC: Return an expression representing traversal of a 1:many or many:many relationship.
public Expression
anyOfAllowingNone(String attributeName, boolean
indicates whether a new expression should be created.
shouldJoinBeIndependent
)

Overrides org.eclipse.persistence.expressions.Expression.anyOfAllowingNone.

ADVANCED: Return an expression representing traversal of a 1:many or many:many relationship.
public int
assignTableAliasesStartingAt(int initialValue)

Overrides org.eclipse.persistence.expressions.Expression.assignTableAliasesStartingAt.

INTERNAL: Assign aliases to any tables which I own.
public void
public ClassDescriptor
convertToCastDescriptor(ClassDescriptor rootDescriptor, AbstractSession session)

INTERNAL Return the descriptor which contains this query key, look in the inheritance hierarchy of rootDescriptor for the descriptor.

public List<Expression>
copyDerivedExpressions(Map<K, V> alreadyDone)

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

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

INTERNAL: Return if the expression is equal to the other.
public QueryKeyExpression
public Expression
get(String attributeName, boolean
- allows the get to not force an inner-join (if getAllowingNull was used elsewhere).
forceInnerJoin
)

Overrides org.eclipse.persistence.expressions.Expression.get.

Return the expression from the attribute dervied from this expression.
public List<DatabaseTable>
getAdditionalTables()

Return any tables in addition to the descriptor's tables, such as the mappings join table.

public Expression
getAllowingNull(String attributeName)

Overrides org.eclipse.persistence.expressions.Expression.getAllowingNull.

ADVANCED: Return an expression that wraps the attribute or query key name.
public Class<?>
public ClassDescriptor
public Vector<E>
getFields()

Overrides org.eclipse.persistence.expressions.Expression.getFields.

INTERNAL: Not to be confused with the public getField(String) This returns a collection of all fields associated with this object.
public ObjectExpression

Returns:

first non-AggregateObjectMapping expression after the base ExpressionBuilder from the fullExpression
getFirstNonAggregateExpressionAfterExpressionBuilder
(List<E>
- collection of aggregateObjectMapping expressions encountered in the returned expression between the first expression and the ExpressionBuilder
aggregateMappingsEncountered
)

INTERNAL: Parses an expression to return the first non-AggregateObjectMapping expression after the base ExpressionBuilder.

protected Vector<E>
getForUpdateOfFields()

INTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking.

public Expression
public Expression
getManualQueryKey(String attributeName, ClassDescriptor aDescriptor)

public Expression
public Integer
public List<DatabaseTable>
getOwnedTables()

Overrides org.eclipse.persistence.expressions.Expression.getOwnedTables.

Return any tables that are defined by this expression (and not its base).
public DatabaseTable
getRelationTable()

Return null by default, only QueryKeyExpression can have a relation table.

public List<DatabaseField>
public boolean
hasBeenAliased()

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

INTERNAL: Answers if the database tables associated with this expression have been aliased.
protected boolean
public boolean
isDirectCollection()

Return false by default, only possible for QueryKeyExpression.

public boolean
isDowncast(ClassDescriptor rootDescriptor, AbstractSession session)

INTERNAL Return true if it uses a cast class and query is downcasting.

public boolean
public boolean
isTreatUsed()

INTERNAL Return true if treat was used on this expression

public boolean
isUsingOuterJoinForMultitableInheritance()

INTERNAL: indicates whether additional expressions for multitable inheritance should be used and are available

public Expression
join(Expression target, Expression onClause)

Overrides org.eclipse.persistence.expressions.Expression.join.

Defines a join between this expression and the target expression based on the ON clause.
public Expression
leftJoin(Expression target, Expression onClause)

Overrides org.eclipse.persistence.expressions.Expression.leftJoin.

Defines a join between this expression and the target expression based on the ON clause.
public QueryKeyExpression
public Expression
protected void
postCopyIn(Map<K, V> alreadyDone)

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

INTERNAL: Used for cloning.
public void
postCopyIn(Map<K, V> alreadyDone, List<Expression> oldDerivedFields, List<Expression> oldDerivedTables)

INTERNAL: The method was added to circumvent derivedFields and derivedTables being protected.

public void
setCastClass(Class<?> castClass)

public void
public void
public void
setOuterJoinExpIndex(Integer outerJoinExpIndex)

public void
setShouldUseOuterJoinForMultitableInheritance(boolean shouldUseOuterJoinForMultitableInheritance)

INTERNAL: set the flag indicating whether subclasses should be joined

public boolean
public boolean
public Expression
treat(Class<?> castClass)

Overrides org.eclipse.persistence.expressions.Expression.treat.

Return an expression that allows you to treat its base as if it were a subclass of the class returned by the base This can only be called on an ExpressionBuilder, the result of expression.get(String), expression.getAllowingNull(String), the result of expression.anyOf("String") or the result of expression.anyOfAllowingNull("String") downcast uses Expression.type() internally to guarantee the results are of the specified class.
public Expression
type()

Overrides org.eclipse.persistence.expressions.Expression.type.

PUBLIC: Return an expression that wraps the inheritance type field in an expression.
protected void
writeForUpdateOfFields(ExpressionSQLPrinter printer, SQLSelectStatement statement)

INTERNAL: writes the first field from each of the owned tables, used for fine-grained pessimistic locking.

Inherited from org.eclipse.persistence.internal.expressions.DataExpression:
addDerivedFieldaddDerivedTablealiasForTableasOfassignAliasassignAliascopyCollectionexistingDerivedFieldexistingDerivedTablegetAliasgetAliasedFieldgetAsOfClausegetContainingDescriptorgetFieldgetFieldgetFieldgetMappinggetQueryKeyOrNullgetTablegetTablegetTableAliaseshasAsOfClausehasBeenNormalizedhasDerivedFieldshasDerivedTablesisAttributeisDataExpressioniterateOnnewDerivedFieldnewDerivedTablenormalizeprintSQLsetHasBeenNormalizedsetTableAliasestableAliasesDescriptionwriteSubexpressionsTo

Field Detail

castClassback to summary
protected Class<?> castClass

Allow an expression node to be cast to a subclass or implementation class.

derivedExpressionsback to summary
public List<Expression> derivedExpressions
descriptorback to summary
protected transient ClassDescriptor descriptor
hasBeenAliasedback to summary
protected boolean hasBeenAliased

Allow hasBeenAliased to be marked independently from the existence of the tableAliases collection.

joinSourceback to summary
protected Expression joinSource

Defines that this expression has been joined to the source expression.

onClauseback to summary
protected Expression onClause

Allow for an ON clause to be specified on a join condition.

outerJoinExpIndexback to summary
private Integer outerJoinExpIndex

Used to track the index of the OuterJoinExpressionHolder that might be associated to this expression

shouldUseOuterJoinback to summary
protected boolean shouldUseOuterJoin

Is this query key to be resolved using an outer join or not. Does not apply to attributes.

shouldUseOuterJoinForMultitableInheritanceback to summary
protected boolean shouldUseOuterJoinForMultitableInheritance

indicates whether subclasses should be joined

Constructor Detail

ObjectExpressionback to summary
protected ObjectExpression()

Method Detail

addDerivedExpressionback to summary
public synchronized void addDerivedExpression(Expression addThis)

INTERNAL: Add the expression as a derived child of this expression. i.e. e.get("name"), "name" is a derived child of "e".

additionalExpressionCriteriaback to summary
public Expression additionalExpressionCriteria()

INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.

additionalExpressionCriteriaMapback to summary
public Map<K, V> additionalExpressionCriteriaMap()

INTERNAL: Used in case outer joins should be printed in FROM clause. Each of the additional tables mapped to expressions that joins it.

anyOfback to summary
public Expression anyOf(String attributeName, boolean shouldJoinBeIndependent)

Overrides org.eclipse.persistence.expressions.Expression.anyOf.

PUBLIC: Return an expression representing traversal of a 1:many or many:many relationship. This allows you to query whether any of the "many" side of the relationship satisfies the remaining criteria.

Example:

    Expression: employee.anyOf("managedEmployees").get("firstName").equal("Bob")
    Java: no direct equivalent
    SQL: SELECT DISTINCT ... WHERE (t2.MGR_ID = t1.ID) AND (t2.F_NAME = 'Bob')
Parameters
shouldJoinBeIndependent:boolean

indicates whether a new expression should be created.

Annotations
@Override
anyOfAllowingNoneback to summary
public Expression anyOfAllowingNone(String attributeName, boolean shouldJoinBeIndependent)

Overrides org.eclipse.persistence.expressions.Expression.anyOfAllowingNone.

ADVANCED: Return an expression representing traversal of a 1:many or many:many relationship. This allows you to query whether any of the "many" side of the relationship satisfies the remaining criteria.

Example:

    Expression: employee.anyOf("managedEmployees").get("firstName").equal("Bob")
    Java: no direct equivalent
    SQL: SELECT DISTINCT ... WHERE (t2.MGR_ID (+) = t1.ID) AND (t2.F_NAME = 'Bob')
Parameters
shouldJoinBeIndependent:boolean

indicates whether a new expression should be created.

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

Overrides org.eclipse.persistence.expressions.Expression.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
clearAliasesback to summary
public void clearAliases()

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

INTERNAL:

Annotations
@Override
convertToCastDescriptorback to summary
public ClassDescriptor convertToCastDescriptor(ClassDescriptor rootDescriptor, AbstractSession session)

INTERNAL Return the descriptor which contains this query key, look in the inheritance hierarchy of rootDescriptor for the descriptor.

copyDerivedExpressionsback to summary
public List<Expression> copyDerivedExpressions(Map<K, V> alreadyDone)
derivedExpressionNamedback to summary
public QueryKeyExpression derivedExpressionNamed(String attributeName)
derivedManualExpressionNamedback to summary
public Expression derivedManualExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
doNotUseOuterJoinback to summary
public void doNotUseOuterJoin()
doUseOuterJoinback to summary
public void doUseOuterJoin()
equalsback to summary
public boolean equals(Object expression)

Overrides org.eclipse.persistence.internal.expressions.DataExpression.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
existingDerivedExpressionNamedback to summary
public QueryKeyExpression existingDerivedExpressionNamed(String attributeName)
getback to summary
public Expression get(String attributeName, boolean forceInnerJoin)

Overrides org.eclipse.persistence.expressions.Expression.get.

Return the expression from the attribute dervied from this expression.

Parameters
forceInnerJoin:boolean

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

- allows the get to not force an inner-join (if getAllowingNull was used elsewhere).

Annotations
@Override
getAdditionalTablesback to summary
public List<DatabaseTable> getAdditionalTables()

Return any tables in addition to the descriptor's tables, such as the mappings join table.

getAllowingNullback to summary
public Expression getAllowingNull(String attributeName)

Overrides org.eclipse.persistence.expressions.Expression.getAllowingNull.

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

ADVANCED: Return an expression that wraps the attribute or query key name. This is only applicable to 1:1 relationships, and allows the target of the relationship to be null if there is no corresponding relationship in the database. Implemented via an outer join in the database.

Example:

 builder.getAllowingNull("address").get("city").equal("Ottawa");
Annotations
@Override
getCastClassback to summary
public Class<?> getCastClass()
getDescriptorback to summary
public ClassDescriptor getDescriptor()

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

Annotations
@Override
getFieldsback to summary
public Vector<E> getFields()

Overrides org.eclipse.persistence.expressions.Expression.getFields.

INTERNAL: Not to be confused with the public getField(String) This returns a collection of all fields associated with this object. Really only applies to query keys representing an object or to expression builders.

Annotations
@Override
getFirstNonAggregateExpressionAfterExpressionBuilderback to summary
public ObjectExpression getFirstNonAggregateExpressionAfterExpressionBuilder(List<E> aggregateMappingsEncountered)

INTERNAL: Parses an expression to return the first non-AggregateObjectMapping expression after the base ExpressionBuilder. This is used by joining and batch fetch to get the list of mappings that really need to be processed (non-aggregates).

Parameters
aggregateMappingsEncountered:List<E>

- collection of aggregateObjectMapping expressions encountered in the returned expression between the first expression and the ExpressionBuilder

Returns:ObjectExpression

first non-AggregateObjectMapping expression after the base ExpressionBuilder from the fullExpression

getForUpdateOfFieldsback to summary
protected Vector<E> getForUpdateOfFields()

INTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking.

getJoinSourceback to summary
public Expression getJoinSource()
getManualQueryKeyback to summary
public Expression getManualQueryKey(String attributeName, ClassDescriptor aDescriptor)
getOnClauseback to summary
public Expression getOnClause()
getOuterJoinExpIndexback to summary
public Integer getOuterJoinExpIndex()
getOwnedTablesback to summary
public List<DatabaseTable> getOwnedTables()

Overrides org.eclipse.persistence.expressions.Expression.getOwnedTables.

Return any tables that are defined by this expression (and not its base).

Annotations
@Override
getRelationTableback to summary
public DatabaseTable getRelationTable()

Return null by default, only QueryKeyExpression can have a relation table.

getSelectionFieldsback to summary
public List<DatabaseField> getSelectionFields(ReadQuery query)

Overrides org.eclipse.persistence.expressions.Expression.getSelectionFields.

INTERNAL:

Annotations
@Override
hasBeenAliasedback to summary
public boolean hasBeenAliased()

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

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

INTERNAL: Answers if the database tables associated with this expression have been aliased. This insures the same tables are not aliased twice.

Annotations
@Override
hasDerivedExpressionsback to summary
protected boolean hasDerivedExpressions()
isDirectCollectionback to summary
public boolean isDirectCollection()

Return false by default, only possible for QueryKeyExpression.

isDowncastback to summary
public boolean isDowncast(ClassDescriptor rootDescriptor, AbstractSession session)

INTERNAL Return true if it uses a cast class and query is downcasting. It will look into inheritance hierarchy of the root descriptor.

isObjectExpressionback to summary
public boolean isObjectExpression()

Overrides org.eclipse.persistence.expressions.Expression.isObjectExpression.

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

INTERNAL:

Annotations
@Override
isTreatUsedback to summary
public boolean isTreatUsed()

INTERNAL Return true if treat was used on this expression

isUsingOuterJoinForMultitableInheritanceback to summary
public boolean isUsingOuterJoinForMultitableInheritance()

INTERNAL: indicates whether additional expressions for multitable inheritance should be used and are available

joinback to summary
public Expression join(Expression target, Expression onClause)

Overrides org.eclipse.persistence.expressions.Expression.join.

Defines a join between this expression and the target expression based on the ON clause.

Annotations
@Override
leftJoinback to summary
public Expression leftJoin(Expression target, Expression onClause)

Overrides org.eclipse.persistence.expressions.Expression.leftJoin.

Defines a join between this expression and the target expression based on the ON clause.

Annotations
@Override
newDerivedExpressionNamedback to summary
public QueryKeyExpression newDerivedExpressionNamed(String attributeName)
newManualDerivedExpressionNamedback to summary
public Expression newManualDerivedExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
postCopyInback to summary
protected void postCopyIn(Map<K, V> alreadyDone)

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

INTERNAL: Used for cloning.

Annotations
@Override
postCopyInback to summary
public void postCopyIn(Map<K, V> alreadyDone, List<Expression> oldDerivedFields, List<Expression> oldDerivedTables)

INTERNAL: The method was added to circumvent derivedFields and derivedTables being protected.

See Also
org.eclipse.persistence.expressions.ExpressionBuilder#registerIn(Map alreadyDone)
setCastClassback to summary
public void setCastClass(Class<?> castClass)
setJoinSourceback to summary
public void setJoinSource(Expression joinSource)
setOnClauseback to summary
public void setOnClause(Expression onClause)
setOuterJoinExpIndexback to summary
public void setOuterJoinExpIndex(Integer outerJoinExpIndex)
setShouldUseOuterJoinForMultitableInheritanceback to summary
public void setShouldUseOuterJoinForMultitableInheritance(boolean shouldUseOuterJoinForMultitableInheritance)

INTERNAL: set the flag indicating whether subclasses should be joined

shouldUseOuterJoinback to summary
public boolean shouldUseOuterJoin()
shouldUseOuterJoinForMultitableInheritanceback to summary
public boolean shouldUseOuterJoinForMultitableInheritance()
treatback to summary
public Expression treat(Class<?> castClass)

Overrides org.eclipse.persistence.expressions.Expression.treat.

Return an expression that allows you to treat its base as if it were a subclass of the class returned by the base This can only be called on an ExpressionBuilder, the result of expression.get(String), expression.getAllowingNull(String), the result of expression.anyOf("String") or the result of expression.anyOfAllowingNull("String") downcast uses Expression.type() internally to guarantee the results are of the specified class.

Example:

    Expression: employee.get("project").as(LargeProject.class).get("budget").equal(1000)
    Java: ((LargeProject)employee.getProjects().get(0)).getBudget() == 1000
    SQL: LPROJ.PROJ_ID (+)= PROJ.PROJ_ID AND L_PROJ.BUDGET = 1000 AND PROJ.TYPE = "L"
Annotations
@Override
typeback to summary
public Expression type()

Overrides org.eclipse.persistence.expressions.Expression.type.

PUBLIC: Return an expression that wraps the inheritance type field in an expression.

Example:

 builder.getClassForInheritance().equal(SmallProject.class);
Annotations
@Override
writeForUpdateOfFieldsback to summary
protected void writeForUpdateOfFields(ExpressionSQLPrinter printer, SQLSelectStatement statement)

INTERNAL: writes the first field from each of the owned tables, used for fine-grained pessimistic locking.