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

public Class TreatAsExpression

extends QueryKeyExpression
Class Inheritance
Imports
java.io.BufferedWriter, .IOException, java.util.HashMap, .List, .Map, .Vector, org.eclipse.persistence.descriptors.ClassDescriptor, .InheritancePolicy, org.eclipse.persistence.exceptions.QueryException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.helper.DatabaseField, .DatabaseTable, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.queries.DatabaseQuery

Author
cdelahun

Field Summary

Modifier and TypeField and Description
protected Boolean
protected Expression
protected ObjectExpression
Inherited from org.eclipse.persistence.internal.expressions.QueryKeyExpression:
aliasedFieldhasMappinghasQueryKeyindexisAttributeExpressionisClonedForSubQuerymappingnamequeryKeyshouldQueryToManyRelationship

Constructor Summary

AccessConstructor and Description
public
TreatAsExpression(Class<?> castClass, ObjectExpression baseExpression)

Method Summary

Modifier and TypeMethod and Description
public Expression
additionalTreatExpressionCriteria()

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

public Map<K, V>
additionalTreatExpressionCriteriaMap()

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

public DatabaseTable
protected void
assignAlias(DatabaseTable alias, DatabaseTable table)

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

INTERNAL: Alias a particular table within this node
public int
assignTableAliasesStartingAt(int initialValue)

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

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

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

INTERNAL - Return the descriptor which contains this query key, look in the inheritance hierarchy of rootDescriptor for the descriptor.
public Expression
convertToUseOuterJoin()

Overrides org.eclipse.persistence.expressions.Expression.convertToUseOuterJoin.

INTERNAL: Modify this expression to use outer joins wherever there are equality operations between two field nodes.
public String
public boolean
equals(Object
the reference object with which to compare.
object
)

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

INTERNAL: Return if the expression is equal to the other.
public List<DatabaseTable>
getAdditionalTables()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getAdditionalTables.

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
public Expression
getAlias(Expression subSelect)

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

ADVANCED: Return an expression representing a sub-select in the from clause.
public ClassDescriptor
public Vector<E>
public Object
getFieldValue(Object objectValue, AbstractSession session)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFieldValue.

INTERNAL: Transform the object-level value into a database-level value
public ClassDescriptor
getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafDescriptor.

INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.
public DatabaseMapping
getLeafMapping(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafMapping.

INTERNAL: Lookup the mapping for this item by traversing its expression recursively.
public List<DatabaseTable>
getOwnedSubTables()

INTERNAL: much like getOwnedTables(), this gets the tables represented from the descriptor.

public List<DatabaseTable>
getOwnedTables()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.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)
public DatabaseTable
getReferenceTable()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getReferenceTable.

Calculate the reference table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).
public DatabaseTable

Returns:

DatabaseTable
getRelationTable
()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getRelationTable.

Calculate the relation table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).
public DatabaseTable
getSourceTable()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getSourceTable.

Calculate the source table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).
public TableAliasLookup
public Expression

Returns:

Expression
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

public Expression
public boolean
hasAsOfClause()

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

ADVANCED: Answers true if this is to be queried as of a past time.
public boolean
isDowncast()

INTERNAL:

public boolean
public Expression
public Expression
normalize(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer)

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

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<K, V> alreadyDone)

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

INTERNAL: Used for cloning.
public void
printJava(ExpressionJavaPrinter printer)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.printJava.

INTERNAL: Print java for project class generation
public void
printSQL(ExpressionSQLPrinter printer)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.printSQL.

INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context
public Expression
rebuildOn(Expression newBase)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.rebuildOn.

INTERNAL: This expression is built on a different base than the one we want.
public boolean
selectIfOrderedBy()

Overrides org.eclipse.persistence.expressions.Expression.selectIfOrderedBy.

PUBLIC: Return whether this expression should be included in the SELECT clause if it is used in an ORDER BY clause
public Expression
twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.twistedForBaseAndContext.

INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression.
public void
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.internal.expressions.QueryKeyExpression.valueFromObject.

INTERNAL: Return the value for in memory comparison.
public Object
valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy)

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

INTERNAL: Return the value for in memory comparison.
public void
writeDescriptionOn(BufferedWriter writer)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.writeDescriptionOn.

INTERNAL: Used to print a debug form of the expression tree.
public void
writeFields(ExpressionSQLPrinter printer, List<DatabaseField> newFields, SQLSelectStatement statement)

Overrides org.eclipse.persistence.expressions.Expression.writeFields.

INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...)
public void
Inherited from org.eclipse.persistence.internal.expressions.QueryKeyExpression:
additionalExpressionCriteriaadditionalExpressionCriteriaMapcheckJoinForSubSelectWithParentcomputeHashCodedoQueryToManyRelationshipgetAliasedFieldgetAliasedTablegetFieldgetMapKeyDescriptorgetMappinggetMappingFromQueryKeygetNamegetNestedAttributeNamegetQueryKeyOrNullgetSelectionFieldsindexinitializeAliasedFieldisAttributeisDirectCollectionisManyToManyisMapKeyObjectRelationshipisOneToManyisOneToOneisQueryKeyExpressionnormalizerebuildOnresetCacheshouldQueryToManyRelationshiptreatvaluesFromCollection

Field Detail

isDowncastback to summary
protected Boolean isDowncast
typeExpressionback to summary
protected Expression typeExpression
typeExpressionBaseback to summary
protected ObjectExpression typeExpressionBase

Constructor Detail

TreatAsExpressionback to summary
public TreatAsExpression(Class<?> castClass, ObjectExpression baseExpression)

Method Detail

additionalTreatExpressionCriteriaback to summary
public Expression additionalTreatExpressionCriteria()

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

additionalTreatExpressionCriteriaMapback to summary
public Map<K, V> additionalTreatExpressionCriteriaMap()

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

aliasForTableback to summary
public DatabaseTable aliasForTable(DatabaseTable table)

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

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.aliasForTable.

INTERNAL: Find the alias for a given table

Annotations
@Override
assignAliasback to summary
protected void assignAlias(DatabaseTable alias, DatabaseTable table)

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

INTERNAL: Alias a particular table within this node

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
convertToCastDescriptorback to summary
public ClassDescriptor convertToCastDescriptor(ClassDescriptor rootDescriptor, AbstractSession session)

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

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.

Annotations
@Override
convertToUseOuterJoinback to summary
public Expression convertToUseOuterJoin()

Overrides org.eclipse.persistence.expressions.Expression.convertToUseOuterJoin.

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

INTERNAL: Modify this expression to use outer joins wherever there are equality operations between two field nodes.

Annotations
@Override
descriptionOfNodeTypeback to summary
public String descriptionOfNodeType()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.descriptionOfNodeType.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.descriptionOfNodeType.

INTERNAL: Used for debug printing.

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

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

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.equals.

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

Parameters
object: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
getAdditionalTablesback to summary
public List<DatabaseTable> getAdditionalTables()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getAdditionalTables.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getAdditionalTables.

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

Annotations
@Override
getAliasback to summary
public Expression getAlias(Expression subSelect)

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

Doc from org.eclipse.persistence.internal.expressions.DataExpression.getAlias.

ADVANCED: Return an expression representing a sub-select in the from clause.

Example:

 builder.getAlias(builder.subQuery(reportQuery)).get("type").equal("S");
Annotations
@Override
getDescriptorback to summary
public ClassDescriptor getDescriptor()

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

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFields.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFields.

INTERNAL: Return all the fields

Annotations
@Override
getFieldValueback to summary
public Object getFieldValue(Object objectValue, AbstractSession session)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFieldValue.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getFieldValue.

INTERNAL: Transform the object-level value into a database-level value

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafDescriptor.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafDescriptor.

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

Annotations
@Override
getLeafMappingback to summary
public DatabaseMapping getLeafMapping(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafMapping.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getLeafMapping.

INTERNAL: Lookup the mapping for this item by traversing its expression recursively. If an aggregate of foreign mapping is found it is traversed.

Annotations
@Override
getOwnedSubTablesback to summary
public List<DatabaseTable> 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

getOwnedTablesback to summary
public List<DatabaseTable> getOwnedTables()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.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)

Annotations
@Override
getReferenceTableback to summary
public DatabaseTable getReferenceTable()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getReferenceTable.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getReferenceTable.

Calculate the reference table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings). Called from SQLSelectStatement#appendFromClauseForOuterJoin.

Returns:DatabaseTable

DatabaseTable

Annotations
@Override
getRelationTableback to summary
public DatabaseTable getRelationTable()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.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 from SQLSelectStatement#appendFromClauseForOuterJoin.

Returns:DatabaseTable

DatabaseTable

Annotations
@Override
getSourceTableback to summary
public DatabaseTable getSourceTable()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.getSourceTable.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.getSourceTable.

Calculate the source table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings). Called from SQLSelectStatement#appendFromClauseForOuterJoin.

Returns:DatabaseTable

DatabaseTable

Annotations
@Override
getTableAliasesback to summary
public TableAliasLookup getTableAliases()

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

Doc from org.eclipse.persistence.internal.expressions.DataExpression.getTableAliases.

INTERNAL: Return the aliases used. For CR#2456 must never lazily initialize as also used for Expression identity.

Annotations
@Override
getTreatCriteriaback to summary
public Expression 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

Expression

getTypeClauseback to summary
public Expression getTypeClause()
hasAsOfClauseback to summary
public boolean hasAsOfClause()

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

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

ADVANCED: Answers true if this is to be queried as of a past time.

Returns:boolean

false from asOf(null); hasAsOfClause().

Annotations
@Override
isDowncastback to summary
public boolean isDowncast()

INTERNAL:

isTreatExpressionback to summary
public boolean isTreatExpression()

Overrides org.eclipse.persistence.expressions.Expression.isTreatExpression.

INTERNAL:

Annotations
@Override
mappingCriteriaback to summary
public Expression mappingCriteria(Expression base)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.mappingCriteria.

Annotations
@Override
normalizeback to summary
public Expression normalize(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer)

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

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.normalize.

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.

Annotations
@Override
postCopyInback to summary
protected void postCopyIn(Map<K, V> alreadyDone)

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

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.postCopyIn.

INTERNAL: Used for cloning.

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.printJava.

INTERNAL: Print java for project class generation

Annotations
@Override
printSQLback to summary
public void printSQL(ExpressionSQLPrinter printer)

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.printSQL.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.printSQL.

INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.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

Annotations
@Override
selectIfOrderedByback to summary
public boolean selectIfOrderedBy()

Overrides org.eclipse.persistence.expressions.Expression.selectIfOrderedBy.

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

PUBLIC: Return whether this expression should be included in the SELECT clause if it is used in an ORDER BY clause

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.twistedForBaseAndContext.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.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
validateNodeback to summary
public void validateNode()

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.validateNode.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.validateNode.

Do any required validation for this node. Throw an exception if it's incorrect.

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.valueFromObject.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.valueFromObject.

INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.

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
valueFromObjectback to summary
public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy)

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

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

INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.

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

Overrides org.eclipse.persistence.internal.expressions.QueryKeyExpression.writeDescriptionOn.

Doc from org.eclipse.persistence.internal.expressions.QueryKeyExpression.writeDescriptionOn.

INTERNAL: Used to print a debug form of the expression tree.

Annotations
@Override
writeFieldsback to summary
public void writeFields(ExpressionSQLPrinter printer, List<DatabaseField> newFields, SQLSelectStatement statement)

Overrides org.eclipse.persistence.expressions.Expression.writeFields.

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

INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...)

Annotations
@Override
writeSubexpressionsToback to summary
public void writeSubexpressionsTo(BufferedWriter writer, int indent) throws IOException

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

Doc from org.eclipse.persistence.internal.expressions.DataExpression.writeSubexpressionsTo.

Print the base for debuggin purposes.

Annotations
@Override