Module org.eclipse.persistence.core
Class QueryKeyExpression
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
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
FromAliasExpression
,ManualQueryKeyExpression
,MapEntryExpression
,TreatAsExpression
Represents expression on query keys or mappings.
This includes direct, relationships query keys and mappings.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected DatabaseField
Cache the aliased field.protected boolean
protected boolean
protected IndexExpression
protected Boolean
PERF: Cache if the expression is an attribute expression.protected boolean
protected DatabaseMapping
Cache the mapping for performance.protected String
The name of the query key.protected QueryKey
Cache the query key for performance.protected boolean
Is this a query across a 1:many or many:many relationship.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 Expression
checkJoinForSubSelectWithParent
(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer) INTERNAL: Check if new expression need to be created for sub queries and re-normalized.int
INTERNAL: Compute a consistent hash-code for the expression.INTERNAL: Used for debug printing.void
INTERNAL: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 MapINTERNAL: Return the field appropriately aliasedprotected DatabaseTable
Return the alias for our tablegetField()
INTERNAL: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: Return if descriptor for the map key mapping where the key is a OneToOne.getName()
INTERNAL:INTERNAL: Returns nested attribute name or nullINTERNAL: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).getSelectionFields
(ReadQuery query) INTERNAL:Calculate the source table for based on the various QueryKeyExpression usages (join query keys, custom defined query keys, or query keys for mappings).index()
protected void
INTERNAL: Alias the database field for our current environmentboolean
INTERNAL: Return if the expression is for a direct mapped attribute.boolean
INTERNAL: Indicates whether this expression corresponds to DirectCollection.boolean
INTERNAL: Indicates whether this expression corresponds to ManyToMany.boolean
INTERNAL: Return if the expression if for a map key mapping where the key is a OneToOne.boolean
INTERNAL: Indicates whether this expression corresponds to OneToMany.boolean
INTERNAL: Indicates whether this expression corresponds to OneToOne.boolean
INTERNAL:mappingCriteria
(Expression base) normalize
(ExpressionNormalizer normalizer) INTERNAL: Normalize the expression into a printable structure.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.rebuildOn
(Expression oldBase, Expression newBase) INTERNAL: A special version of rebuildOn where the newBase need not be a new ExpressionBuilder but any expression.protected void
Reset cached information here so that we can be sure we're accurate.boolean
ADVANCED: 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.twistedForBaseAndContext
(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, boolean isObjectUnregistered) INTERNAL: Return the value for in memory comparison.valuesFromCollection
(Object object, AbstractSession session, int valueHolderPolicy, boolean isObjectUnregistered) INTERNAL This method iterates through a collection and gets the values from the objects to conform in an in-memory query.void
writeDescriptionOn
(BufferedWriter writer) INTERNAL: Used to print a debug form of the expression tree.Methods inherited from class org.eclipse.persistence.internal.expressions.ObjectExpression
addDerivedExpression, anyOf, anyOfAllowingNone, assignTableAliasesStartingAt, clearAliases, convertToCastDescriptor, copyDerivedExpressions, derivedExpressionNamed, derivedManualExpressionNamed, doNotUseOuterJoin, doUseOuterJoin, existingDerivedExpressionNamed, get, getAllowingNull, getCastClass, getDescriptor, 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, assignAlias, copyCollection, existingDerivedField, existingDerivedTable, getAlias, getAsOfClause, getContainingDescriptor, getField, getField, getTable, getTable, getTableAliases, hasAsOfClause, hasBeenNormalized, hasDerivedFields, hasDerivedTables, isDataExpression, iterateOn, newDerivedField, newDerivedTable, 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, 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, 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, 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, ref, regexp, regexp, registerIn, replace, replicate, replicate, 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, union, union, unionAll, unionAll, value, value, value, value, value, value, value, value, value, value, valueFromObject, variance, writeAlias, writeField, writeFields
-
Field Details
-
name
The name of the query key. -
aliasedField
Cache the aliased field. Only applies to attributes. -
shouldQueryToManyRelationship
protected boolean shouldQueryToManyRelationshipIs this a query across a 1:many or many:many relationship. Does not apply to attributes. -
queryKey
Cache the query key for performance. Store a boolean so we don't repeat the search if there isn't one. -
hasQueryKey
protected boolean hasQueryKey -
mapping
Cache the mapping for performance. Store a boolean so we don't repeat the search if there isn't one. -
hasMapping
protected boolean hasMapping -
isAttributeExpression
PERF: Cache if the expression is an attribute expression. -
index
-
isClonedForSubQuery
protected boolean isClonedForSubQuery
-
-
Constructor Details
-
QueryKeyExpression
public QueryKeyExpression() -
QueryKeyExpression
-
-
Method Details
-
equals
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 classObjectExpression
-
computeHashCode
public int computeHashCode()INTERNAL: Compute a consistent hash-code for the expression. This is used to allow dynamic expression's SQL to be cached.- Overrides:
computeHashCode
in classExpression
-
additionalExpressionCriteria
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.- Overrides:
additionalExpressionCriteria
in classObjectExpression
-
additionalExpressionCriteriaMap
INTERNAL: Used in case outer joins should be printed in FROM clause. Each of the additional tables mapped to expressions that joins it.- Overrides:
additionalExpressionCriteriaMap
in classObjectExpression
-
aliasForTable
INTERNAL: Find the alias for a given table- Overrides:
aliasForTable
in classDataExpression
-
treat
ADVANCED: 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:
EclipseLink: employee.get("project").treat(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 classObjectExpression
-
postCopyIn
INTERNAL: Used for cloning.- Overrides:
postCopyIn
in classObjectExpression
-
descriptionOfNodeType
INTERNAL: Used for debug printing.- Overrides:
descriptionOfNodeType
in classExpression
-
doQueryToManyRelationship
public void doQueryToManyRelationship()INTERNAL: -
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- Overrides:
getAdditionalTables
in classObjectExpression
-
getAliasedField
INTERNAL: Return the field appropriately aliased- Overrides:
getAliasedField
in classDataExpression
-
getAliasedTable
Return the alias for our table -
getField
INTERNAL:- Overrides:
getField
in classDataExpression
-
getFields
INTERNAL: Return all the fields- Overrides:
getFields
in classObjectExpression
-
getSelectionFields
INTERNAL:- Overrides:
getSelectionFields
in classObjectExpression
-
getFieldValue
INTERNAL: Transform the object-level value into a database-level value- Overrides:
getFieldValue
in classExpression
-
getMapping
- Overrides:
getMapping
in classDataExpression
-
getMappingFromQueryKey
-
getName
Description copied from class:Expression
INTERNAL:- Overrides:
getName
in classExpression
-
getNestedAttributeName
INTERNAL: Returns nested attribute name or null -
getOwnedTables
INTERNAL:- Overrides:
getOwnedTables
in classObjectExpression
-
getQueryKeyOrNull
- Overrides:
getQueryKeyOrNull
in classDataExpression
-
index
- Overrides:
index
in classExpression
-
initializeAliasedField
protected void initializeAliasedField()INTERNAL: Alias the database field for our current environment -
isAttribute
public boolean isAttribute()INTERNAL: Return if the expression is for a direct mapped attribute.- Overrides:
isAttribute
in classDataExpression
-
isQueryKeyExpression
public boolean isQueryKeyExpression()Description copied from class:Expression
INTERNAL:- Overrides:
isQueryKeyExpression
in classExpression
-
mappingCriteria
-
normalize
INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.- Overrides:
normalize
in classDataExpression
-
checkJoinForSubSelectWithParent
protected Expression checkJoinForSubSelectWithParent(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer) INTERNAL: Check if new expression need to be created for sub queries and re-normalized. -
normalize
public Expression 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. -
printSQL
INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context- Overrides:
printSQL
in classDataExpression
-
printJava
INTERNAL: Print java for project class generation- Overrides:
printJava
in classExpression
-
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- Specified by:
rebuildOn
in classExpression
- See Also:
-
rebuildOn
INTERNAL: A special version of rebuildOn where the newBase need not be a new ExpressionBuilder but any expression.For nested joined attributes, the joined attribute query must have its joined attributes rebuilt relative to it.
-
resetCache
protected void resetCache()Reset cached information here so that we can be sure we're accurate.- Overrides:
resetCache
in classExpression
-
shouldQueryToManyRelationship
public boolean shouldQueryToManyRelationship() -
twistedForBaseAndContext
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase) 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 classExpression
-
validateNode
public void validateNode()Do any required validation for this node. Throw an exception if it's incorrect.- Overrides:
validateNode
in classExpression
-
valueFromObject
public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, int valueHolderPolicy, boolean isObjectUnregistered) INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.- Overrides:
valueFromObject
in classExpression
- Parameters:
isObjectUnregistered
- true if object possibly not a clone, but is being conformed against the unit of work cache.
-
valuesFromCollection
public Object valuesFromCollection(Object object, AbstractSession session, int valueHolderPolicy, boolean isObjectUnregistered) INTERNAL This method iterates through a collection and gets the values from the objects to conform in an in-memory query. -
getLeafDescriptor
public ClassDescriptor getLeafDescriptor(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) INTERNAL: Lookup the descriptor for this item by traversing its expression recursively.- Overrides:
getLeafDescriptor
in classExpression
-
getLeafMapping
public DatabaseMapping getLeafMapping(DatabaseQuery query, ClassDescriptor rootDescriptor, AbstractSession session) 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 classExpression
-
writeDescriptionOn
INTERNAL: Used to print a debug form of the expression tree.- Overrides:
writeDescriptionOn
in classExpression
- Throws:
IOException
-
isDirectCollection
public boolean isDirectCollection()INTERNAL: Indicates whether this expression corresponds to DirectCollection.- Overrides:
isDirectCollection
in classObjectExpression
-
isOneToOne
public boolean isOneToOne()INTERNAL: Indicates whether this expression corresponds to OneToOne. -
isOneToMany
public boolean isOneToMany()INTERNAL: Indicates whether this expression corresponds to OneToMany. -
isManyToMany
public boolean isManyToMany()INTERNAL: Indicates whether this expression corresponds to ManyToMany. -
isMapKeyObjectRelationship
public boolean isMapKeyObjectRelationship()INTERNAL: Return if the expression if for a map key mapping where the key is a OneToOne. -
getMapKeyDescriptor
INTERNAL: Return if descriptor for the map key mapping where the key is a OneToOne. -
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 fromSQLSelectStatement.appendFromClauseForOuterJoin(org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter, java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable>, java.util.Collection, boolean)
.- Returns:
- DatabaseTable
-
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 fromSQLSelectStatement.appendFromClauseForOuterJoin(org.eclipse.persistence.internal.expressions.ExpressionSQLPrinter, java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable>, java.util.Collection, boolean)
.- Returns:
- DatabaseTable
-
getRelationTable
Calculate the relation 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:
getRelationTable
in classObjectExpression
- Returns:
- DatabaseTable
-