Module org.eclipse.persistence.core
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
Superclass for any object type expressions.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Class<?> Allow an expression node to be cast to a subclass or implementation class.protected ClassDescriptorprotected booleanAllow hasBeenAliased to be marked independently from the existence of the tableAliases collection.protected ExpressionDefines that this expression has been joined to the source expression.protected ExpressionAllow for an ON clause to be specified on a join condition.protected booleanIs this query key to be resolved using an outer join or not.protected booleanindicates whether subclasses should be joinedFields inherited from class org.eclipse.persistence.internal.expressions.DataExpression
asOfClause, derivedFields, derivedTables, hasBeenNormalized, tableAliasesFields inherited from class org.eclipse.persistence.internal.expressions.BaseExpression
baseExpression, builderFields inherited from class org.eclipse.persistence.expressions.Expression
currentAlias, hashCode, lastTable, selectIfOrderedBy, shouldUseUpperCaseForIgnoreCase -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDerivedExpression(Expression addThis) INTERNAL: Add the expression as a derived child of this expression.INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.INTERNAL: Used in case outer joins should be printed in FROM clause.PUBLIC: Return an expression representing traversal of a 1:many or many:many relationship.anyOfAllowingNone(String attributeName, boolean shouldJoinBeIndependent) ADVANCED: Return an expression representing traversal of a 1:many or many:many relationship.intassignTableAliasesStartingAt(int initialValue) INTERNAL: Assign aliases to any tables which I own.voidINTERNAL: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(Map alreadyDone) derivedExpressionNamed(String attributeName) derivedManualExpressionNamed(String attributeName, ClassDescriptor aDescriptor) voidvoidbooleanINTERNAL: Return if the expression is equal to the other.existingDerivedExpressionNamed(String attributeName) Return the expression from the attribute dervied from this expression.Return any tables in addition to the descriptor's tables, such as the mappings join table.getAllowingNull(String attributeName) ADVANCED: Return an expression that wraps the attribute or query key name.Class<?> INTERNAL: Not to be confused with the public getField(String) This returns a collection of all fields associated with this object.getFirstNonAggregateExpressionAfterExpressionBuilder(List aggregateMappingsEncountered) INTERNAL: Parses an expression to return the first non-AggregateObjectMapping expression after the base ExpressionBuilder.protected VectorINTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking.getManualQueryKey(String attributeName, ClassDescriptor aDescriptor) Return any tables that are defined by this expression (and not its base).Return null by default, only QueryKeyExpression can have a relation table.getSelectionFields(ReadQuery query) INTERNAL:booleanINTERNAL: Answers if the database tables associated with this expression have been aliased.protected booleanbooleanReturn false by default, only possible for QueryKeyExpression.booleanisDowncast(ClassDescriptor rootDescriptor, AbstractSession session) INTERNAL Return true if it uses a cast class and query is downcasting.booleanINTERNAL:booleanINTERNAL Return true if treat was used on this expressionbooleanINTERNAL: indicates whether additional expressions for multitable inheritance should be used and are availablejoin(Expression target, Expression onClause) Defines a join between this expression and the target expression based on the ON clause.leftJoin(Expression target, Expression onClause) Defines a join between this expression and the target expression based on the ON clause.newDerivedExpressionNamed(String attributeName) newManualDerivedExpressionNamed(String attributeName, ClassDescriptor aDescriptor) protected voidpostCopyIn(Map alreadyDone) INTERNAL: Used for cloning.voidpostCopyIn(Map alreadyDone, List<Expression> oldDerivedFields, List<Expression> oldDerivedTables) INTERNAL: The method was added to circumvent derivedFields and derivedTables being protected.voidsetCastClass(Class<?> castClass) voidsetJoinSource(Expression joinSource) voidsetOnClause(Expression onClause) voidsetOuterJoinExpIndex(Integer outerJoinExpIndex) voidsetShouldUseOuterJoinForMultitableInheritance(boolean shouldUseOuterJoinForMultitableInheritance) INTERNAL: set the flag indicating whether subclasses should be joinedbooleanbooleanReturn 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.type()PUBLIC: Return an expression that wraps the inheritance type field in an expression.protected voidwriteForUpdateOfFields(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, writeSubexpressionsToMethods inherited from class org.eclipse.persistence.internal.expressions.BaseExpression
getBaseExpression, getBuilder, resetPlaceHolderBuilder, setBaseExpression, shallowCloneMethods 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, localDate, localDateTime, localTime, 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 Details
-
descriptor
-
derivedExpressions
-
shouldUseOuterJoinForMultitableInheritance
protected boolean shouldUseOuterJoinForMultitableInheritanceindicates whether subclasses should be joined -
shouldUseOuterJoin
protected boolean shouldUseOuterJoinIs this query key to be resolved using an outer join or not. Does not apply to attributes. -
castClass
Allow an expression node to be cast to a subclass or implementation class. -
joinSource
Defines that this expression has been joined to the source expression. -
onClause
Allow for an ON clause to be specified on a join condition. -
hasBeenAliased
protected boolean hasBeenAliasedAllow hasBeenAliased to be marked independently from the existence of the tableAliases collection.
-
-
Constructor Details
-
ObjectExpression
protected ObjectExpression()
-
-
Method Details
-
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"- Overrides:
treatin classExpression
-
equals
INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.- Overrides:
equalsin classDataExpression
-
addDerivedExpression
INTERNAL: Add the expression as a derived child of this expression. i.e. e.get("name"), "name" is a derived child of "e". -
additionalExpressionCriteria
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables. -
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:
assignTableAliasesStartingAtin classExpression
-
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')- Overrides:
anyOfin classExpression- Parameters:
shouldJoinBeIndependent- indicates whether a new expression should be created.
-
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')- Overrides:
anyOfAllowingNonein classExpression- Parameters:
shouldJoinBeIndependent- indicates whether a new expression should be created.
-
isDowncast
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
-
derivedExpressionNamed
-
derivedManualExpressionNamed
-
doNotUseOuterJoin
public void doNotUseOuterJoin() -
doUseOuterJoin
public void doUseOuterJoin() -
existingDerivedExpressionNamed
-
get
Return the expression from the attribute dervied from this expression.- Overrides:
getin classExpression- Parameters:
forceInnerJoin- - allows the get to not force an inner-join (if getAllowingNull was used elsewhere).
-
leftJoin
Defines a join between this expression and the target expression based on the ON clause.- Overrides:
leftJoinin classExpression
-
join
Defines a join between this expression and the target expression based on the ON clause.- Overrides:
joinin classExpression
-
getAllowingNull
Description copied from class:ExpressionADVANCED: 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:
getAllowingNullin classExpression
-
getCastClass
-
type
PUBLIC: Return an expression that wraps the inheritance type field in an expression.Example:
builder.getClassForInheritance().equal(SmallProject.class);
- Overrides:
typein classExpression
-
getDescriptor
- Overrides:
getDescriptorin classDataExpression
-
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:
getFieldsin classExpression
-
getSelectionFields
INTERNAL:- Overrides:
getSelectionFieldsin classExpression
-
getForUpdateOfFields
INTERNAL: Returns the first field from each of the owned tables, used for fine-grained pessimistic locking. -
getManualQueryKey
-
getAdditionalTables
Return any tables in addition to the descriptor's tables, such as the mappings join table. -
getOwnedTables
Return any tables that are defined by this expression (and not its base).- Overrides:
getOwnedTablesin classExpression
-
hasBeenAliased
public boolean hasBeenAliased()Description copied from class:ExpressionINTERNAL: Answers if the database tables associated with this expression have been aliased. This insures the same tables are not aliased twice.- Overrides:
hasBeenAliasedin classDataExpression
-
clearAliases
public void clearAliases()INTERNAL:- Overrides:
clearAliasesin classDataExpression
-
hasDerivedExpressions
protected boolean hasDerivedExpressions() -
isObjectExpression
public boolean isObjectExpression()Description copied from class:ExpressionINTERNAL:- Overrides:
isObjectExpressionin classExpression
-
isUsingOuterJoinForMultitableInheritance
public boolean isUsingOuterJoinForMultitableInheritance()INTERNAL: indicates whether additional expressions for multitable inheritance should be used and are available -
newDerivedExpressionNamed
-
newManualDerivedExpressionNamed
public Expression newManualDerivedExpressionNamed(String attributeName, ClassDescriptor aDescriptor) -
postCopyIn
INTERNAL: Used for cloning.- Overrides:
postCopyInin classDataExpression
-
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.- See Also:
-
getOnClause
-
setOnClause
-
setCastClass
-
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
INTERNAL: writes the first field from each of the owned tables, used for fine-grained pessimistic locking. -
getJoinSource
-
setJoinSource
-
getOuterJoinExpIndex
-
setOuterJoinExpIndex
-
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
-