Class SubSelectExpression
- java.lang.Object
-
- org.eclipse.persistence.expressions.Expression
-
- org.eclipse.persistence.internal.expressions.BaseExpression
-
- org.eclipse.persistence.internal.expressions.SubSelectExpression
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class SubSelectExpression extends BaseExpression
This is used to support subselects. The subselect represents a mostly independent (has own expression builder) query using a report query. Subselects can be used for, in (single column), exists (empty or non-empty), comparisons (single value).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringattributeprotected ExpressioncriteriaBaseprotected booleanhasBeenNormalizedprotected java.lang.ClassreturnTypeprotected ReportQuerysubQuery-
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
Constructors Constructor Description SubSelectExpression()SubSelectExpression(ReportQuery query, Expression baseExpression)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SubSelectExpressioncreateSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, java.lang.String attribute, java.lang.Class returnType)INTERNAL: This factory method is used to build a subselect that will do a count.java.lang.StringdescriptionOfNodeType()INTERNAL: Used in debug printing of this node.booleanequals(java.lang.Object object)INTERNAL: Return if the expression is equal to the other.ReportQuerygetSubQuery()protected voidinitializeCountSubQuery()INTERNAL: This method creates a report query that counts the number of values in baseExpression.anyOf(attribute) For most queries, a ReportQuery will be created that does a simple count using an anonymous query.booleanisSubSelectExpression()INTERNAL:voiditerateOn(ExpressionIterator iterator)INTERNAL: For iterating using an inner classExpressionnormalize(ExpressionNormalizer normalizer)INTERNAL: The subquery must be normalized with the knowledge of the outer statement for outer references and correct aliasing.ExpressionnormalizeSubSelect(ExpressionNormalizer normalizer, java.util.Map clonedExpressions)INTERNAL: Normalize this expression now that the parent statement has been normalized.protected voidpostCopyIn(java.util.Map alreadyDone)The query must be cloned, and the sub-expression must be cloned using the same outer expression identity.protected voidprintCustomSQL(ExpressionSQLPrinter printer)Print the sub query to the printer.voidprintSQL(ExpressionSQLPrinter printer)Print the sub query to the printer.ExpressionrebuildOn(Expression newBase)Should not rebuild as has its on expression builder.voidresetPlaceHolderBuilder(ExpressionBuilder queryBuilder)INTERNAL: Search the tree for any expressions (like SubSelectExpressions) that have been built using a builder that is not attached to the query.voidsetSubQuery(ReportQuery subQuery)ExpressiontwistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression.voidwriteDescriptionOn(java.io.BufferedWriter writer)INTERNAL: Used to print a debug form of the expression tree.voidwriteFields(ExpressionSQLPrinter printer, java.util.Vector newFields, SQLSelectStatement statement)INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...) This allows a sub query in the select clause.voidwriteSubexpressionsTo(java.io.BufferedWriter writer, int indent)INTERNAL: Used in SQL printing.-
Methods inherited from class org.eclipse.persistence.internal.expressions.BaseExpression
getBaseExpression, getBuilder, setBaseExpression, shallowClone
-
Methods inherited from class org.eclipse.persistence.expressions.Expression
addDate, addDate, addMonths, addMonths, alias, aliasForTable, all, 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, any, anyOf, anyOf, anyOfAllowingNone, anyOfAllowingNone, as, as, ascending, asciiValue, asOf, assignAlias, assignTableAliasesStartingAt, average, between, between, between, between, between, between, between, between, between, caseConditionStatement, caseConditionStatement, caseStatement, caseStatement, cast, clone, cloneUsing, coalesce, coalesce, computeHashCode, concat, containsAllKeyWords, containsAnyKeyWords, containsSubstring, containsSubstring, containsSubstringIgnoringCase, containsSubstringIgnoringCase, convertNodeToUseOuterJoin, convertToUseOuterJoin, copiedVersionFrom, count, create, create, createWithBaseLast, currentDate, currentDateDate, currentTime, currentTimeStamp, dateDifference, dateDifference, dateName, datePart, dateToString, decode, descending, 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, get, getAlias, getAllowingNull, getAsOfClause, getAsOfClauseRecursively, getClonedField, getField, getField, getFields, getFieldValue, getFunction, getFunction, getFunction, getFunction, getFunction, getFunctionWithArguments, getFunctionWithArguments, getLeafDescriptor, getLeafMapping, getName, getNumberVal, getOperator, getOperator, getOwnedTables, getParameter, getParameter, getParameter, getProperty, getSelectionFields, getSelectionFields, getSession, getStringVal, getTable, getTable, getTableAliases, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, greaterThanEqual, hasAsOfClause, hasBeenAliased, hashCode, hexToRaw, ifNull, in, in, in, in, in, in, in, in, in, in, in, in, index, indexOf, intersect, intersect, intersectAll, intersectAll, isClassTypeExpression, isCompoundExpression, isConstantExpression, isDataExpression, isEmpty, isExpressionBuilder, isFieldExpression, isFragment, isFunctionExpression, isLiteralExpression, isLogicalExpression, isMapEntryExpression, isNull, isObjectExpression, isParameterExpression, isQueryKeyExpression, isRelationExpression, isTableExpression, isTreatExpression, isValueExpression, join, lastDay, leftJoin, 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, locate, locate, locate, mapEntry, mapKey, maximum, minimum, monthsBetween, newTime, nextDay, noneOf, not, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notBetween, notEmpty, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notExists, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notIn, notLike, notLike, notLike, notLike, notNull, nullIf, nullsFirst, nullsLast, operator, or, performOperator, postfixSQL, prefixSQL, printJava, ref, regexp, regexp, registerIn, replace, replicate, replicate, resetCache, reverse, right, right, rightPad, rightPad, rightTrim, rightTrim, roundDate, selectIfOrderedBy, setLocalBase, setSelectIfOrderedBy, size, size, some, some, some, some, some, some, some, some, some, some, some, some, some, sql, standardDeviation, subQuery, substring, substring, substring, substring, sum, toChar, toChar, toCharacter, toDate, toLowerCase, toNumber, toString, toString, toUpperCase, toUppercaseCasedWords, translate, treat, trim, trim, truncateDate, twist, type, union, union, unionAll, unionAll, validateNode, value, value, value, value, value, value, value, value, value, value, valueFromObject, valueFromObject, variance, writeAlias, writeField
-
-
-
-
Field Detail
-
hasBeenNormalized
protected boolean hasBeenNormalized
-
subQuery
protected ReportQuery subQuery
-
attribute
protected java.lang.String attribute
-
returnType
protected java.lang.Class returnType
-
criteriaBase
protected Expression criteriaBase
-
-
Constructor Detail
-
SubSelectExpression
public SubSelectExpression()
-
SubSelectExpression
public SubSelectExpression(ReportQuery query, Expression baseExpression)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
INTERNAL: Return if the expression is equal to the other. This is used to allow dynamic expression's SQL to be cached.- Overrides:
equalsin classExpression
-
descriptionOfNodeType
public java.lang.String descriptionOfNodeType()
INTERNAL: Used in debug printing of this node.- Overrides:
descriptionOfNodeTypein classExpression
-
getSubQuery
public ReportQuery getSubQuery()
-
initializeCountSubQuery
protected void initializeCountSubQuery()
INTERNAL: This method creates a report query that counts the number of values in baseExpression.anyOf(attribute) For most queries, a ReportQuery will be created that does a simple count using an anonymous query. In the case of a DirectCollectionMapping, the ReportQuery will use the baseExpression to create a join to the table containing the Direct fields and count based on that join.
-
isSubSelectExpression
public boolean isSubSelectExpression()
INTERNAL:- Overrides:
isSubSelectExpressionin classExpression
-
iterateOn
public void iterateOn(ExpressionIterator iterator)
INTERNAL: For iterating using an inner class- Overrides:
iterateOnin classExpression
-
normalize
public Expression normalize(ExpressionNormalizer normalizer)
INTERNAL: The subquery must be normalized with the knowledge of the outer statement for outer references and correct aliasing. For CR#4223 it will now be normalized after the outer statement is, rather than somewhere in the middle of the outer statement's normalize.- Overrides:
normalizein classExpression
-
normalizeSubSelect
public Expression normalizeSubSelect(ExpressionNormalizer normalizer, java.util.Map clonedExpressions)
INTERNAL: Normalize this expression now that the parent statement has been normalized. For CR#4223
-
postCopyIn
protected void postCopyIn(java.util.Map alreadyDone)
The query must be cloned, and the sub-expression must be cloned using the same outer expression identity.- Overrides:
postCopyInin classBaseExpression
-
printCustomSQL
protected void printCustomSQL(ExpressionSQLPrinter printer)
Print the sub query to the printer.
-
printSQL
public void printSQL(ExpressionSQLPrinter printer)
Print the sub query to the printer.- Specified by:
printSQLin classExpression
-
rebuildOn
public Expression rebuildOn(Expression newBase)
Should not rebuild as has its on expression builder.- Specified by:
rebuildOnin classExpression- See Also:
Expression.cloneUsing(Expression newBase)
-
resetPlaceHolderBuilder
public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)
INTERNAL: Search the tree for any expressions (like SubSelectExpressions) that have been built using a builder that is not attached to the query. This happens in case of an Exists call using a new ExpressionBuilder(). This builder needs to be replaced with one from the query.- Overrides:
resetPlaceHolderBuilderin classBaseExpression
-
setSubQuery
public void setSubQuery(ReportQuery subQuery)
-
twistedForBaseAndContext
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)
Description copied from class:ExpressionINTERNAL: 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
-
writeDescriptionOn
public void writeDescriptionOn(java.io.BufferedWriter writer) throws java.io.IOExceptionINTERNAL: Used to print a debug form of the expression tree.- Overrides:
writeDescriptionOnin classExpression- Throws:
java.io.IOException
-
writeSubexpressionsTo
public void writeSubexpressionsTo(java.io.BufferedWriter writer, int indent) throws java.io.IOExceptionINTERNAL: Used in SQL printing.- Overrides:
writeSubexpressionsToin classExpression- Throws:
java.io.IOException
-
writeFields
public void writeFields(ExpressionSQLPrinter printer, java.util.Vector newFields, SQLSelectStatement statement)
INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...) This allows a sub query in the select clause.- Overrides:
writeFieldsin classExpression
-
createSubSelectExpressionForCount
public static SubSelectExpression createSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, java.lang.String attribute, java.lang.Class returnType)
INTERNAL: This factory method is used to build a subselect that will do a count. It will count the number of items in baseExpression.anyOf(attribute).
-
-