Module org.eclipse.persistence.core
Class TreatAsExpression
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
org.eclipse.persistence.internal.expressions.QueryKeyExpression
org.eclipse.persistence.internal.expressions.TreatAsExpression
- All Implemented Interfaces:
Serializable
,Cloneable
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Boolean
protected Expression
protected ObjectExpression
Fields inherited from class org.eclipse.persistence.internal.expressions.QueryKeyExpression
aliasedField, hasMapping, hasQueryKey, index, isAttributeExpression, isClonedForSubQuery, mapping, name, queryKey, shouldQueryToManyRelationship
Fields inherited from class org.eclipse.persistence.internal.expressions.ObjectExpression
castClass, derivedExpressions, descriptor, hasBeenAliased, joinSource, onClause, shouldUseOuterJoin, shouldUseOuterJoinForMultitableInheritance
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
-
Method Summary
Modifier and TypeMethodDescriptionINTERNAL: 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.aliasForTable
(DatabaseTable table) INTERNAL: Find the alias for a given tableprotected void
assignAlias
(DatabaseTable alias, DatabaseTable table) INTERNAL: Alias a particular table within this nodeint
assignTableAliasesStartingAt
(int initialValue) INTERNAL: Assign aliases to any tables which I own.convertToCastDescriptor
(ClassDescriptor rootDescriptor, AbstractSession session) INTERNAL - Return the descriptor which contains this query key, look in the inheritance hierarchy of rootDescriptor for the descriptor.INTERNAL: Modify this expression to use outer joins wherever there are equality operations between two field nodes.INTERNAL: Used for debug printing.boolean
INTERNAL: Return if the expression is equal to the other.INTERNAL: Return any additional tables that belong to this expression An example of how this method is used is to return any tables that belong to the map key when this expression traverses a mapping that uses a MapgetAlias
(Expression subSelect) ADVANCED: Return an expression representing a sub-select in the from clause.INTERNAL: Return all the fieldsgetFieldValue
(Object objectValue, AbstractSession session) INTERNAL: Transform the object-level value into a database-level valuegetLeafDescriptor
(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.getLeafMapping
(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) INTERNAL: Lookup the mapping for this item by traversing its expression recursively.INTERNAL: much like getOwnedTables(), this gets the tables represented from the descriptor.This owns (can access) the child's extra tables as well as its parent's tables so we should pull these from super (which gets them from the current descriptor)Calculate the reference table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).Calculate the relation table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).Calculate the source table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).INTERNAL: Return the aliases used.INTERNAL: this returns a single expression to represent the join from the main table to all child descriptor tables Only if outer joins should be printed in the where clauseboolean
ADVANCED: Answers true ifthis
is to be queried as of a past time.boolean
INTERNAL:boolean
INTERNAL:mappingCriteria
(Expression base) normalize
(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer) INTERNAL: For CR#2456 if this is part of an objExp.equal(objExp), do not need to add additional expressions to normalizer both times, and the foreign key join replaces the equal expression.protected void
postCopyIn
(Map alreadyDone) INTERNAL: Used for cloning.void
printJava
(ExpressionJavaPrinter printer) INTERNAL: Print java for project class generationvoid
printSQL
(ExpressionSQLPrinter printer) INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for contextrebuildOn
(Expression newBase) INTERNAL: This expression is built on a different base than the one we want.boolean
PUBLIC: Return whether this expression should be included in the SELECT clause if it is used in an ORDER BY clausetwistedForBaseAndContext
(Expression newBase, Expression context, Expression oldBase) INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression.void
Do any required validation for this node.valueFromObject
(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy) INTERNAL: Return the value for in memory comparison.valueFromObject
(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) INTERNAL: Return the value for in memory comparison.void
writeDescriptionOn
(BufferedWriter writer) INTERNAL: Used to print a debug form of the expression tree.void
writeFields
(ExpressionSQLPrinter printer, List<DatabaseField> newFields, SQLSelectStatement statement) INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...)void
writeSubexpressionsTo
(BufferedWriter writer, int indent) Print the base for debuggin purposes.Methods inherited from class org.eclipse.persistence.internal.expressions.QueryKeyExpression
additionalExpressionCriteria, additionalExpressionCriteriaMap, checkJoinForSubSelectWithParent, computeHashCode, doQueryToManyRelationship, getAliasedField, getAliasedTable, getField, getMapKeyDescriptor, getMapping, getMappingFromQueryKey, getName, getNestedAttributeName, getQueryKeyOrNull, getSelectionFields, index, initializeAliasedField, isAttribute, isDirectCollection, isManyToMany, isMapKeyObjectRelationship, isOneToMany, isOneToOne, isQueryKeyExpression, normalize, rebuildOn, resetCache, shouldQueryToManyRelationship, treat, valuesFromCollection
Methods inherited from class org.eclipse.persistence.internal.expressions.ObjectExpression
addDerivedExpression, anyOf, anyOfAllowingNone, clearAliases, copyDerivedExpressions, derivedExpressionNamed, derivedManualExpressionNamed, doNotUseOuterJoin, doUseOuterJoin, existingDerivedExpressionNamed, get, getAllowingNull, getCastClass, getFirstNonAggregateExpressionAfterExpressionBuilder, getForUpdateOfFields, getJoinSource, getManualQueryKey, getOnClause, getOuterJoinExpIndex, hasBeenAliased, hasDerivedExpressions, isDowncast, isObjectExpression, isTreatUsed, isUsingOuterJoinForMultitableInheritance, join, leftJoin, newDerivedExpressionNamed, newManualDerivedExpressionNamed, postCopyIn, setCastClass, setJoinSource, setOnClause, setOuterJoinExpIndex, setShouldUseOuterJoinForMultitableInheritance, shouldUseOuterJoin, shouldUseOuterJoinForMultitableInheritance, type, writeForUpdateOfFields
Methods inherited from class org.eclipse.persistence.internal.expressions.DataExpression
addDerivedField, addDerivedTable, asOf, assignAlias, copyCollection, existingDerivedField, existingDerivedTable, getAsOfClause, getContainingDescriptor, getField, getField, getTable, getTable, hasBeenNormalized, hasDerivedFields, hasDerivedTables, isDataExpression, iterateOn, newDerivedField, newDerivedTable, setHasBeenNormalized, setTableAliases, tableAliasesDescription
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, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertNodeToUseOuterJoin, copiedVersionFrom, count, create, create, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, 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, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, 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, indexOf, intersect, intersect, intersectAll, intersectAll, isClassTypeExpression, isCompoundExpression, isConstantExpression, isEmpty, isExpressionBuilder, isFieldExpression, isFragment, isFunctionExpression, isLiteralExpression, isLogicalExpression, isMapEntryExpression, isNull, isParameterExpression, isRelationExpression, isSubSelectExpression, isTableExpression, 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, ref, regexp, regexp, registerIn, replace, replicate, replicate, reverse, right, right, rightPad, rightPad, rightTrim, rightTrim, roundDate, 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, union, union, unionAll, unionAll, value, value, value, value, value, value, value, value, value, value, variance, writeAlias, writeField
-
Field Details
-
typeExpressionBase
-
typeExpression
-
isDowncast
-
-
Constructor Details
-
TreatAsExpression
-
-
Method Details
-
convertToUseOuterJoin
Description copied from class:Expression
INTERNAL: Modify this expression to use outer joins wherever there are equality operations between two field nodes.- Overrides:
convertToUseOuterJoin
in classExpression
-
descriptionOfNodeType
Description copied from class:QueryKeyExpression
INTERNAL: Used for debug printing.- Overrides:
descriptionOfNodeType
in classQueryKeyExpression
-
equals
Description copied from class:QueryKeyExpression
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 classQueryKeyExpression
-
getFields
Description copied from class:QueryKeyExpression
INTERNAL: Return all the fields- Overrides:
getFields
in classQueryKeyExpression
-
getFieldValue
Description copied from class:QueryKeyExpression
INTERNAL: Transform the object-level value into a database-level value- Overrides:
getFieldValue
in classQueryKeyExpression
-
getOwnedTables
This owns (can access) the child's extra tables as well as its parent's tables so we should pull these from super (which gets them from the current descriptor)- Overrides:
getOwnedTables
in classQueryKeyExpression
-
getAlias
Description copied from class:DataExpression
ADVANCED: Return an expression representing a sub-select in the from clause.Example:
builder.getAlias(builder.subQuery(reportQuery)).get("type").equal("S");
- Overrides:
getAlias
in classDataExpression
-
getRelationTable
Calculate the relation table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings). Does not apply to Treat Called fromSQLSelectStatement.appendFromClauseForOuterJoin(org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter, java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable>, java.util.Collection, boolean)
.- Overrides:
getRelationTable
in classQueryKeyExpression
- Returns:
- DatabaseTable
-
getTableAliases
Description copied from class:DataExpression
INTERNAL: Return the aliases used. For CR#2456 must never lazily initialize as also used for Expression identity.- Overrides:
getTableAliases
in classDataExpression
-
hasAsOfClause
public boolean hasAsOfClause()Description copied from class:Expression
ADVANCED: Answers true ifthis
is to be queried as of a past time.- Overrides:
hasAsOfClause
in classDataExpression
- Returns:
- false from
asOf(null); hasAsOfClause()
. - See Also:
-
isDowncast
public boolean isDowncast()INTERNAL: -
isTreatExpression
public boolean isTreatExpression()INTERNAL:- Overrides:
isTreatExpression
in classExpression
-
printSQL
Description copied from class:QueryKeyExpression
INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context- Overrides:
printSQL
in classQueryKeyExpression
-
selectIfOrderedBy
public boolean selectIfOrderedBy()Description copied from class:Expression
PUBLIC: Return whether this expression should be included in the SELECT clause if it is used in an ORDER BY clause- Overrides:
selectIfOrderedBy
in classExpression
-
twistedForBaseAndContext
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) Description copied from class:QueryKeyExpression
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"- Overrides:
twistedForBaseAndContext
in classQueryKeyExpression
-
validateNode
public void validateNode()Description copied from class:QueryKeyExpression
Do any required validation for this node. Throw an exception if it's incorrect.- Overrides:
validateNode
in classQueryKeyExpression
-
valueFromObject
public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) Description copied from class:QueryKeyExpression
INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.- Overrides:
valueFromObject
in classQueryKeyExpression
- Parameters:
isObjectUnregistered
- true if object possibly not a clone, but is being conformed against the unit of work cache.
-
valueFromObject
public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy) Description copied from class:Expression
INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.- Overrides:
valueFromObject
in classExpression
-
writeDescriptionOn
Description copied from class:QueryKeyExpression
INTERNAL: Used to print a debug form of the expression tree.- Overrides:
writeDescriptionOn
in classQueryKeyExpression
- Throws:
IOException
-
writeFields
public void writeFields(ExpressionSQLPrinter printer, List<DatabaseField> newFields, SQLSelectStatement statement) Description copied from class:Expression
INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...)- Overrides:
writeFields
in classExpression
-
writeSubexpressionsTo
Description copied from class:DataExpression
Print the base for debuggin purposes.- Overrides:
writeSubexpressionsTo
in classDataExpression
- Throws:
IOException
-
getLeafDescriptor
public ClassDescriptor getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) Description copied from class:QueryKeyExpression
INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.- Overrides:
getLeafDescriptor
in classQueryKeyExpression
-
getLeafMapping
public DatabaseMapping getLeafMapping(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) Description copied from class:QueryKeyExpression
INTERNAL: Lookup the mapping for this item by traversing its expression recursively. If an aggregate of foreign mapping is found it is traversed.- Overrides:
getLeafMapping
in classQueryKeyExpression
-
aliasForTable
Description copied from class:QueryKeyExpression
INTERNAL: Find the alias for a given table- Overrides:
aliasForTable
in classQueryKeyExpression
-
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- Overrides:
rebuildOn
in classQueryKeyExpression
- See Also:
-
getDescriptor
- Overrides:
getDescriptor
in classObjectExpression
-
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. Does not set the descriptor, only returns it.- Overrides:
convertToCastDescriptor
in classObjectExpression
-
getTypeClause
-
postCopyIn
Description copied from class:QueryKeyExpression
INTERNAL: Used for cloning.- Overrides:
postCopyIn
in classQueryKeyExpression
-
printJava
INTERNAL: Print java for project class generation- Overrides:
printJava
in classQueryKeyExpression
-
assignAlias
INTERNAL: Alias a particular table within this node- Overrides:
assignAlias
in classDataExpression
-
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 classObjectExpression
-
getOwnedSubTables
INTERNAL: much like getOwnedTables(), this gets the tables represented from the descriptor. Difference is this only returns local tables for the child casted descriptor, and excludes tables owned by the parent descriptor -
getAdditionalTables
Description copied from class:QueryKeyExpression
INTERNAL: Return any additional tables that belong to this expression An example of how this method is used is to return any tables that belong to the map key when this expression traverses a mapping that uses a Map- Overrides:
getAdditionalTables
in classQueryKeyExpression
-
mappingCriteria
- Overrides:
mappingCriteria
in classQueryKeyExpression
-
additionalTreatExpressionCriteriaMap
INTERNAL: Used in case outer joins should be printed in FROM clause. Each of the additional tables mapped to expressions that joins it. -
getTreatCriteria
INTERNAL: this returns a single expression to represent the join from the main table to all child descriptor tables Only if outer joins should be printed in the where clause- Returns:
- Expression
-
additionalTreatExpressionCriteria
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables. -
getSourceTable
Description copied from class:QueryKeyExpression
Calculate the source table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings). Called fromSQLSelectStatement.appendFromClauseForOuterJoin(org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter, java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable>, java.util.Collection, boolean)
.- Overrides:
getSourceTable
in classQueryKeyExpression
- Returns:
- DatabaseTable
-
getReferenceTable
Description copied from class:QueryKeyExpression
Calculate the reference table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings). Called fromSQLSelectStatement.appendFromClauseForOuterJoin(org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter, java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable>, java.util.Collection, boolean)
.- Overrides:
getReferenceTable
in classQueryKeyExpression
- Returns:
- DatabaseTable
-
normalize
public Expression normalize(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer) Description copied from class:QueryKeyExpression
INTERNAL: For CR#2456 if this is part of an objExp.equal(objExp), do not need to add additional expressions to normalizer both times, and the foreign key join replaces the equal expression.- Overrides:
normalize
in classQueryKeyExpression
-