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
FieldsModifier and TypeFieldDescriptionprotected DatabaseFieldCache the aliased field.protected booleanprotected booleanprotected IndexExpressionprotected BooleanPERF: Cache if the expression is an attribute expression.protected booleanprotected DatabaseMappingCache the mapping for performance.protected StringThe name of the query key.protected QueryKeyCache the query key for performance.protected booleanIs 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, shouldUseOuterJoinForMultitableInheritanceFields 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 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 ExpressioncheckJoinForSubSelectWithParent(ExpressionNormalizer normalizer, Expression base, List<Expression> foreignKeyJoinPointer) INTERNAL: Check if new expression need to be created for sub queries and re-normalized.intINTERNAL: Compute a consistent hash-code for the expression.INTERNAL: Used for debug printing.voidINTERNAL:booleanINTERNAL: 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 DatabaseTableReturn 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 voidINTERNAL: Alias the database field for our current environmentbooleanINTERNAL: Return if the expression is for a direct mapped attribute.booleanINTERNAL: Indicates whether this expression corresponds to DirectCollection.booleanINTERNAL: Indicates whether this expression corresponds to ManyToMany.booleanINTERNAL: Return if the expression if for a map key mapping where the key is a OneToOne.booleanINTERNAL: Indicates whether this expression corresponds to OneToMany.booleanINTERNAL: Indicates whether this expression corresponds to OneToOne.booleanINTERNAL: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 voidpostCopyIn(Map alreadyDone) INTERNAL: Used for cloning.voidprintJava(ExpressionJavaPrinter printer) INTERNAL: Print java for project class generationvoidprintSQL(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 voidReset cached information here so that we can be sure we're accurate.booleanADVANCED: 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.voidDo 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.voidwriteDescriptionOn(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, writeForUpdateOfFieldsMethods 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, 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, 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:
equalsin 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:
computeHashCodein classExpression
-
additionalExpressionCriteria
INTERNAL: Return the expression to join the main table of this node to any auxiliary tables.- Overrides:
additionalExpressionCriteriain 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:
additionalExpressionCriteriaMapin classObjectExpression
-
aliasForTable
INTERNAL: Find the alias for a given table- Overrides:
aliasForTablein 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:
treatin classObjectExpression
-
postCopyIn
INTERNAL: Used for cloning.- Overrides:
postCopyInin classObjectExpression
-
descriptionOfNodeType
INTERNAL: Used for debug printing.- Overrides:
descriptionOfNodeTypein 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:
getAdditionalTablesin classObjectExpression
-
getAliasedField
INTERNAL: Return the field appropriately aliased- Overrides:
getAliasedFieldin classDataExpression
-
getAliasedTable
Return the alias for our table -
getField
INTERNAL:- Overrides:
getFieldin classDataExpression
-
getFields
INTERNAL: Return all the fields- Overrides:
getFieldsin classObjectExpression
-
getSelectionFields
INTERNAL:- Overrides:
getSelectionFieldsin classObjectExpression
-
getFieldValue
INTERNAL: Transform the object-level value into a database-level value- Overrides:
getFieldValuein classExpression
-
getMapping
- Overrides:
getMappingin classDataExpression
-
getMappingFromQueryKey
-
getName
Description copied from class:ExpressionINTERNAL:- Overrides:
getNamein classExpression
-
getNestedAttributeName
INTERNAL: Returns nested attribute name or null -
getOwnedTables
INTERNAL:- Overrides:
getOwnedTablesin classObjectExpression
-
getQueryKeyOrNull
- Overrides:
getQueryKeyOrNullin classDataExpression
-
index
- Overrides:
indexin 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:
isAttributein classDataExpression
-
isQueryKeyExpression
public boolean isQueryKeyExpression()Description copied from class:ExpressionINTERNAL:- Overrides:
isQueryKeyExpressionin classExpression
-
mappingCriteria
-
normalize
INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.- Overrides:
normalizein 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:
printSQLin classDataExpression
-
printJava
INTERNAL: Print java for project class generation- Overrides:
printJavain 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:
rebuildOnin 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:
resetCachein 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:
twistedForBaseAndContextin classExpression
-
validateNode
public void validateNode()Do any required validation for this node. Throw an exception if it's incorrect.- Overrides:
validateNodein 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:
valueFromObjectin 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:
getLeafDescriptorin 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:
getLeafMappingin classExpression
-
writeDescriptionOn
INTERNAL: Used to print a debug form of the expression tree.- Overrides:
writeDescriptionOnin classExpression- Throws:
IOException
-
isDirectCollection
public boolean isDirectCollection()INTERNAL: Indicates whether this expression corresponds to DirectCollection.- Overrides:
isDirectCollectionin 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:
getRelationTablein classObjectExpression- Returns:
- DatabaseTable
-