Class ObjectExpression
- java.lang.Object
-
- org.eclipse.persistence.expressions.Expression
-
- org.eclipse.persistence.internal.expressions.BaseExpression
-
- org.eclipse.persistence.internal.expressions.DataExpression
-
- org.eclipse.persistence.internal.expressions.ObjectExpression
-
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ExpressionBuilder
,QueryKeyExpression
public abstract class ObjectExpression extends DataExpression
Superclass for any object type expressions.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Class
castClass
Allow an expression node to be cast to a subclass or implementation class.List<Expression>
derivedExpressions
protected ClassDescriptor
descriptor
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.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-
Fields inherited from class org.eclipse.persistence.internal.expressions.DataExpression
asOfClause, derivedFields, derivedTables, hasBeenNormalized, tableAliases
-
Fields inherited from class org.eclipse.persistence.internal.expressions.BaseExpression
baseExpression, builder
-
Fields inherited from class org.eclipse.persistence.expressions.Expression
currentAlias, hashCode, lastTable, selectIfOrderedBy, shouldUseUpperCaseForIgnoreCase
-
-
Constructor Summary
Constructors Constructor Description ObjectExpression()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDerivedExpression(Expression addThis)
INTERNAL: Add the expression as a derived child of this expression.Expression
additionalExpressionCriteria()
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.Map
additionalExpressionCriteriaMap()
INTERNAL: Used in case outer joins should be printed in FROM clause.Expression
anyOf(String attributeName, boolean shouldJoinBeIndependent)
PUBLIC: Return an expression representing traversal of a 1:many or many:many relationship.Expression
anyOfAllowingNone(String attributeName, boolean shouldJoinBeIndependent)
ADVANCED: Return an expression representing traversal of a 1:many or many:many relationship.int
assignTableAliasesStartingAt(int initialValue)
INTERNAL: Assign aliases to any tables which I own.void
clearAliases()
INTERNAL: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.List<Expression>
copyDerivedExpressions(Map alreadyDone)
QueryKeyExpression
derivedExpressionNamed(String attributeName)
Expression
derivedManualExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
void
doNotUseOuterJoin()
void
doUseOuterJoin()
boolean
equals(Object expression)
INTERNAL: Return if the expression is equal to the other.QueryKeyExpression
existingDerivedExpressionNamed(String attributeName)
Expression
get(String attributeName, boolean forceInnerJoin)
Return the expression from the attribute dervied from this expression.List<DatabaseTable>
getAdditionalTables()
Return any tables in addition to the descriptor's tables, such as the mappings join table.Expression
getAllowingNull(String attributeName)
ADVANCED: Return an expression that wraps the attribute or query key name.Class
getCastClass()
ClassDescriptor
getDescriptor()
Vector
getFields()
INTERNAL: Not to be confused with the public getField(String) This returns a collection of all fields associated with this object.ObjectExpression
getFirstNonAggregateExpressionAfterExpressionBuilder(List aggregateMappingsEncountered)
INTERNAL: Parses an expression to return the first non-AggregateObjectMapping expression after the base ExpressionBuilder.protected Vector
getForUpdateOfFields()
INTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking.Expression
getJoinSource()
Expression
getManualQueryKey(String attributeName, ClassDescriptor aDescriptor)
Expression
getOnClause()
Integer
getOuterJoinExpIndex()
List<DatabaseTable>
getOwnedTables()
Return any tables that are defined by this expression (and not its base).DatabaseTable
getRelationTable()
Return null by default, only QueryKeyExpression can have a relation table.List<DatabaseField>
getSelectionFields(ReadQuery query)
INTERNAL:boolean
hasBeenAliased()
INTERNAL: Answers if the database tables associated with this expression have been aliased.protected boolean
hasDerivedExpressions()
boolean
isDirectCollection()
Return false by default, only possible for QueryKeyExpression.boolean
isDowncast(ClassDescriptor rootDescriptor, AbstractSession session)
INTERNAL Return true if it uses a cast class and query is downcasting.boolean
isObjectExpression()
INTERNAL:boolean
isTreatUsed()
INTERNAL Return true if treat was used on this expressionboolean
isUsingOuterJoinForMultitableInheritance()
INTERNAL: indicates whether additional expressions for multitable inheritance should be used and are availableExpression
join(Expression target, Expression onClause)
Defines a join between this expression and the target expression based on the ON clause.Expression
leftJoin(Expression target, Expression onClause)
Defines a join between this expression and the target expression based on the ON clause.QueryKeyExpression
newDerivedExpressionNamed(String attributeName)
Expression
newManualDerivedExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
protected void
postCopyIn(Map alreadyDone)
INTERNAL: Used for cloning.void
postCopyIn(Map alreadyDone, List<Expression> oldDerivedFields, List<Expression> oldDerivedTables)
INTERNAL: The method was added to circumvent derivedFields and derivedTables being protected.void
setCastClass(Class castClass)
void
setJoinSource(Expression joinSource)
void
setOnClause(Expression onClause)
void
setOuterJoinExpIndex(Integer outerJoinExpIndex)
void
setShouldUseOuterJoinForMultitableInheritance(boolean shouldUseOuterJoinForMultitableInheritance)
INTERNAL: set the flag indicating whether subclasses should be joinedboolean
shouldUseOuterJoin()
boolean
shouldUseOuterJoinForMultitableInheritance()
Expression
treat(Class castClass)
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.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.-
Methods inherited from class org.eclipse.persistence.internal.expressions.DataExpression
addDerivedField, addDerivedTable, aliasForTable, asOf, assignAlias, assignAlias, copyCollection, existingDerivedField, existingDerivedTable, getAlias, getAliasedField, getAsOfClause, getContainingDescriptor, getField, getField, getField, getMapping, getQueryKeyOrNull, getTable, getTable, getTableAliases, hasAsOfClause, hasBeenNormalized, hasDerivedFields, hasDerivedTables, isAttribute, isDataExpression, iterateOn, newDerivedField, newDerivedTable, normalize, printSQL, setHasBeenNormalized, setTableAliases, tableAliasesDescription, writeSubexpressionsTo
-
Methods inherited from class org.eclipse.persistence.internal.expressions.BaseExpression
getBaseExpression, getBuilder, resetPlaceHolderBuilder, setBaseExpression, shallowClone
-
Methods inherited from class org.eclipse.persistence.expressions.Expression
addDate, addDate, addMonths, addMonths, alias, all, all, all, all, all, all, all, all, all, all, all, all, allOf, and, any, any, any, any, any, any, any, any, any, any, any, any, anyOf, anyOfAllowingNone, as, ascending, asciiValue, average, between, between, between, between, between, between, between, between, between, caseConditionStatement, caseConditionStatement, caseStatement, caseStatement, cast, clone, cloneUsing, coalesce, coalesce, computeHashCode, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertNodeToUseOuterJoin, convertToUseOuterJoin, copiedVersionFrom, count, create, create, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, descriptionOfNodeType, difference, distinct, doesConform, doesConform, equal, equal, equal, equal, equal, equal, equal, equal, equal, equal, equalOuterJoin, equalOuterJoin, equalsIgnoreCase, equalsIgnoreCase, except, except, exceptAll, exceptAll, exists, existsNode, extract, extractFields, extractPrimaryKeyValues, extractValue, extractValues, extractXml, from, fromConstant, fromLiteral, get, getAsOfClauseRecursively, getClonedField, getFieldValue, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, getLeafDescriptor, getLeafMapping, getName, getNumberVal, getOperator, getOperator, getParameter, getParameter, getParameter, getProperty, getSelectionFields, getSession, getStringVal, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, hashCode, hexToRaw, ifNull, in, in, in, in, in, in, in, in, in, in, in, in, index, indexOf, intersect, intersect, intersectAll, intersectAll, isClassTypeExpression, isCompoundExpression, isConstantExpression, isEmpty, isExpressionBuilder, isFieldExpression, isFragment, isFunctionExpression, isLiteralExpression, isLogicalExpression, isMapEntryExpression, isNull, isParameterExpression, isQueryKeyExpression, isRelationExpression, isSubSelectExpression, isTableExpression, isTreatExpression, isValueExpression, lastDay, leftPad, leftPad, leftTrim, leftTrim, length, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThan, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, lessThanEqual, like, like, like, like, likeIgnoreCase, likeIgnoreCase, literal, locate, locate, locate, mapEntry, mapKey, maximum, minimum, monthsBetween, newTime, nextDay, noneOf, not, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notEmpty, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notExists, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notLike, notLike, notLike, notLike, notNull, nullIf, nullsFirst, nullsLast, operator, or, performOperator, postfixSQL, prefixSQL, printJava, rebuildOn, ref, regexp, regexp, registerIn, replace, replicate, replicate, resetCache, reverse, right, right, rightPad, rightPad, rightTrim, rightTrim, roundDate, selectIfOrderedBy, setLocalBase, setSelectIfOrderedBy, size, size, some, some, some, some, some, some, some, some, some, some, some, some, sql, standardDeviation, subQuery, substring, substring, substring, substring, sum, toChar, toChar, toCharacter, toDate, toLowerCase, toNumber, toString, toString, toUpperCase, toUppercaseCasedWords, translate, trim, trim, truncateDate, twist, twistedForBaseAndContext, union, union, unionAll, unionAll, validateNode, value, value, value, value, value, value, value, value, value, value, valueFromObject, valueFromObject, variance, writeAlias, writeDescriptionOn, writeField, writeFields
-
-
-
-
Field Detail
-
descriptor
protected transient ClassDescriptor descriptor
-
derivedExpressions
public List<Expression> derivedExpressions
-
shouldUseOuterJoinForMultitableInheritance
protected boolean shouldUseOuterJoinForMultitableInheritance
indicates whether subclasses should be joined
-
shouldUseOuterJoin
protected boolean shouldUseOuterJoin
Is this query key to be resolved using an outer join or not. Does not apply to attributes.
-
castClass
protected Class castClass
Allow an expression node to be cast to a subclass or implementation class.
-
joinSource
protected Expression joinSource
Defines that this expression has been joined to the source expression.
-
onClause
protected Expression onClause
Allow for an ON clause to be specified on a join condition.
-
hasBeenAliased
protected boolean hasBeenAliased
Allow hasBeenAliased to be marked independently from the existence of the tableAliases collection.
-
-
Method Detail
-
treat
public Expression treat(Class castClass)
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"
- Overrides:
treat
in classExpression
-
equals
public boolean equals(Object expression)
INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.- Overrides:
equals
in classDataExpression
-
addDerivedExpression
public 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".
-
additionalExpressionCriteria
public Expression additionalExpressionCriteria()
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.
-
additionalExpressionCriteriaMap
public Map additionalExpressionCriteriaMap()
INTERNAL: Used in case outer joins should be printed in FROM clause. Each of the additional tables mapped to expressions that joins it.
-
assignTableAliasesStartingAt
public int assignTableAliasesStartingAt(int initialValue)
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.- Overrides:
assignTableAliasesStartingAt
in classExpression
-
anyOf
public Expression anyOf(String attributeName, boolean shouldJoinBeIndependent)
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')
- Overrides:
anyOf
in classExpression
- Parameters:
shouldJoinBeIndependent
- indicates whether a new expression should be created.
-
anyOfAllowingNone
public Expression anyOfAllowingNone(String attributeName, boolean shouldJoinBeIndependent)
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')
- Overrides:
anyOfAllowingNone
in classExpression
- Parameters:
shouldJoinBeIndependent
- indicates whether a new expression should be created.
-
isDowncast
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.
-
isTreatUsed
public boolean isTreatUsed()
INTERNAL Return true if treat was used on this expression
-
convertToCastDescriptor
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.
-
copyDerivedExpressions
public List<Expression> copyDerivedExpressions(Map alreadyDone)
-
derivedExpressionNamed
public QueryKeyExpression derivedExpressionNamed(String attributeName)
-
derivedManualExpressionNamed
public Expression derivedManualExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
-
doNotUseOuterJoin
public void doNotUseOuterJoin()
-
doUseOuterJoin
public void doUseOuterJoin()
-
existingDerivedExpressionNamed
public QueryKeyExpression existingDerivedExpressionNamed(String attributeName)
-
get
public Expression get(String attributeName, boolean forceInnerJoin)
Return the expression from the attribute dervied from this expression.- Overrides:
get
in classExpression
forceInnerJoin
- - allows the get to not force an inner-join (if getAllowingNull was used elsewhere).
-
leftJoin
public Expression leftJoin(Expression target, Expression onClause)
Defines a join between this expression and the target expression based on the ON clause.- Overrides:
leftJoin
in classExpression
-
join
public Expression join(Expression target, Expression onClause)
Defines a join between this expression and the target expression based on the ON clause.- Overrides:
join
in classExpression
-
getAllowingNull
public Expression getAllowingNull(String attributeName)
Description copied from class:Expression
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");
- Overrides:
getAllowingNull
in classExpression
-
getCastClass
public Class getCastClass()
-
type
public Expression type()
PUBLIC: Return an expression that wraps the inheritance type field in an expression.Example:
builder.getClassForInheritance().equal(SmallProject.class);
- Overrides:
type
in classExpression
-
getDescriptor
public ClassDescriptor getDescriptor()
- Overrides:
getDescriptor
in classDataExpression
-
getFields
public Vector 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.- Overrides:
getFields
in classExpression
-
getSelectionFields
public List<DatabaseField> getSelectionFields(ReadQuery query)
INTERNAL:- Overrides:
getSelectionFields
in classExpression
-
getForUpdateOfFields
protected Vector getForUpdateOfFields()
INTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking.
-
getManualQueryKey
public Expression getManualQueryKey(String attributeName, ClassDescriptor aDescriptor)
-
getAdditionalTables
public List<DatabaseTable> getAdditionalTables()
Return any tables in addition to the descriptor's tables, such as the mappings join table.
-
getOwnedTables
public List<DatabaseTable> getOwnedTables()
Return any tables that are defined by this expression (and not its base).- Overrides:
getOwnedTables
in classExpression
-
hasBeenAliased
public boolean hasBeenAliased()
Description copied from class:Expression
INTERNAL: Answers if the database tables associated with this expression have been aliased. This insures the same tables are not aliased twice.- Overrides:
hasBeenAliased
in classDataExpression
-
clearAliases
public void clearAliases()
INTERNAL:- Overrides:
clearAliases
in classDataExpression
-
hasDerivedExpressions
protected boolean hasDerivedExpressions()
-
isObjectExpression
public boolean isObjectExpression()
Description copied from class:Expression
INTERNAL:- Overrides:
isObjectExpression
in classExpression
-
isUsingOuterJoinForMultitableInheritance
public boolean isUsingOuterJoinForMultitableInheritance()
INTERNAL: indicates whether additional expressions for multitable inheritance should be used and are available
-
newDerivedExpressionNamed
public QueryKeyExpression newDerivedExpressionNamed(String attributeName)
-
newManualDerivedExpressionNamed
public Expression newManualDerivedExpressionNamed(String attributeName, ClassDescriptor aDescriptor)
-
postCopyIn
protected void postCopyIn(Map alreadyDone)
INTERNAL: Used for cloning.- Overrides:
postCopyIn
in classDataExpression
-
getRelationTable
public DatabaseTable getRelationTable()
Return null by default, only QueryKeyExpression can have a relation table.
-
isDirectCollection
public boolean isDirectCollection()
Return false by default, only possible for QueryKeyExpression.
-
postCopyIn
public void postCopyIn(Map alreadyDone, List<Expression> oldDerivedFields, List<Expression> oldDerivedTables)
INTERNAL: The method was added to circumvent derivedFields and derivedTables being protected.
-
getOnClause
public Expression getOnClause()
-
setOnClause
public void setOnClause(Expression onClause)
-
setCastClass
public void setCastClass(Class castClass)
-
setShouldUseOuterJoinForMultitableInheritance
public void setShouldUseOuterJoinForMultitableInheritance(boolean shouldUseOuterJoinForMultitableInheritance)
INTERNAL: set the flag indicating whether subclasses should be joined
-
shouldUseOuterJoin
public boolean shouldUseOuterJoin()
-
shouldUseOuterJoinForMultitableInheritance
public boolean shouldUseOuterJoinForMultitableInheritance()
-
writeForUpdateOfFields
protected void writeForUpdateOfFields(ExpressionSQLPrinter printer, SQLSelectStatement statement)
INTERNAL: writes the first field from each of the owned tables, used for fine-grained pessimistic locking.
-
getJoinSource
public Expression getJoinSource()
-
setJoinSource
public void setJoinSource(Expression joinSource)
-
getOuterJoinExpIndex
public Integer getOuterJoinExpIndex()
-
setOuterJoinExpIndex
public void setOuterJoinExpIndex(Integer outerJoinExpIndex)
-
getFirstNonAggregateExpressionAfterExpressionBuilder
public ObjectExpression getFirstNonAggregateExpressionAfterExpressionBuilder(List 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
- - collection of aggregateObjectMapping expressions encountered in the returned expression between the first expression and the ExpressionBuilder- Returns:
- first non-AggregateObjectMapping expression after the base ExpressionBuilder from the fullExpression
-
-