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

public Class SubSelectExpression

extends BaseExpression
Class Inheritance
Imports
java.io.BufferedWriter, .IOException, java.util.ArrayList, .List, .Map, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.expressions.Expression, .ExpressionBuilder, org.eclipse.persistence.internal.helper.DatabaseField, org.eclipse.persistence.internal.queries.ExpressionQueryMechanism, .ReportItem, .StatementQueryMechanism, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.queries.ReportQuery, .SQLCall

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).

Field Summary

Modifier and TypeField and Description
protected String
protected Expression
protected boolean
protected Class<?>
protected ReportQuery
Inherited from org.eclipse.persistence.internal.expressions.BaseExpression:
baseExpressionbuilder

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public static SubSelectExpression
createSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, String attribute, Class<?> returnType)

INTERNAL: This factory method is used to build a subselect that will do a count.

public String
descriptionOfNodeType()

Overrides org.eclipse.persistence.expressions.Expression.descriptionOfNodeType.

INTERNAL: Used in debug printing of this node.
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides org.eclipse.persistence.expressions.Expression.equals.

INTERNAL: Return if the expression is equal to the other.
public ReportQuery
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.

public boolean
public void
iterateOn(ExpressionIterator iterator)

Overrides org.eclipse.persistence.expressions.Expression.iterateOn.

INTERNAL: For iterating using an inner class
public Expression
normalize(ExpressionNormalizer normalizer)

Overrides org.eclipse.persistence.expressions.Expression.normalize.

INTERNAL: The subquery must be normalized with the knowledge of the outer statement for outer references and correct aliasing.
public Expression
normalizeSubSelect(ExpressionNormalizer normalizer, Map<K, V> clonedExpressions)

INTERNAL: Normalize this expression now that the parent statement has been normalized.

protected void
postCopyIn(Map<K, V> alreadyDone)

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

The query must be cloned, and the sub-expression must be cloned using the same outer expression identity.
protected void
printCustomSQL(ExpressionSQLPrinter printer)

Print the sub query to the printer.

public void
printSQL(ExpressionSQLPrinter printer)

Implements abstract org.eclipse.persistence.expressions.Expression.printSQL.

Print the sub query to the printer.
public Expression
rebuildOn(Expression newBase)

Implements abstract org.eclipse.persistence.expressions.Expression.rebuildOn.

Should not rebuild as has its on expression builder.
public void
resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.resetPlaceHolderBuilder.

INTERNAL: Search the tree for any expressions (like SubSelectExpressions) that have been built using a builder that is not attached to the query.
public void
public Expression
twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)

Overrides org.eclipse.persistence.expressions.Expression.twistedForBaseAndContext.

INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression.
public void
writeDescriptionOn(BufferedWriter writer)

Overrides org.eclipse.persistence.expressions.Expression.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(...) This allows a sub query in the select clause.
public void
Inherited from org.eclipse.persistence.internal.expressions.BaseExpression:
getBaseExpressiongetBuildersetBaseExpressionshallowClone

Field Detail

attributeback to summary
protected String attribute
criteriaBaseback to summary
protected Expression criteriaBase
hasBeenNormalizedback to summary
protected boolean hasBeenNormalized
returnTypeback to summary
protected Class<?> returnType
subQueryback to summary
protected ReportQuery subQuery

Constructor Detail

SubSelectExpressionback to summary
public SubSelectExpression()
SubSelectExpressionback to summary
public SubSelectExpression(ReportQuery query, Expression baseExpression)

Method Detail

createSubSelectExpressionForCountback to summary
public static SubSelectExpression createSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, String attribute, 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).

descriptionOfNodeTypeback to summary
public String descriptionOfNodeType()

Overrides org.eclipse.persistence.expressions.Expression.descriptionOfNodeType.

INTERNAL: Used in debug printing of this node.

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

Overrides org.eclipse.persistence.expressions.Expression.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
getSubQueryback to summary
public ReportQuery getSubQuery()
initializeCountSubQueryback to summary
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.

isSubSelectExpressionback to summary
public boolean isSubSelectExpression()

Overrides org.eclipse.persistence.expressions.Expression.isSubSelectExpression.

INTERNAL:

Annotations
@Override
iterateOnback to summary
public void iterateOn(ExpressionIterator iterator)

Overrides org.eclipse.persistence.expressions.Expression.iterateOn.

INTERNAL: For iterating using an inner class

Annotations
@Override
normalizeback to summary
public Expression normalize(ExpressionNormalizer normalizer)

Overrides org.eclipse.persistence.expressions.Expression.normalize.

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.

Annotations
@Override
normalizeSubSelectback to summary
public Expression normalizeSubSelect(ExpressionNormalizer normalizer, Map<K, V> clonedExpressions)

INTERNAL: Normalize this expression now that the parent statement has been normalized. For CR#4223

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

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

The query must be cloned, and the sub-expression must be cloned using the same outer expression identity.

Annotations
@Override
printCustomSQLback to summary
protected void printCustomSQL(ExpressionSQLPrinter printer)

Print the sub query to the printer.

printSQLback to summary
public void printSQL(ExpressionSQLPrinter printer)

Implements abstract org.eclipse.persistence.expressions.Expression.printSQL.

Print the sub query to the printer.

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

Implements abstract org.eclipse.persistence.expressions.Expression.rebuildOn.

Should not rebuild as has its on expression builder.

Annotations
@Override
resetPlaceHolderBuilderback to summary
public void resetPlaceHolderBuilder(ExpressionBuilder queryBuilder)

Overrides org.eclipse.persistence.internal.expressions.BaseExpression.resetPlaceHolderBuilder.

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.

Annotations
@Override
setSubQueryback to summary
public void setSubQuery(ReportQuery subQuery)
twistedForBaseAndContextback to summary
public Expression twistedForBaseAndContext(Expression newBase, Expression context, Expression oldBase)

Overrides org.eclipse.persistence.expressions.Expression.twistedForBaseAndContext.

Doc from org.eclipse.persistence.expressions.Expression.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
writeDescriptionOnback to summary
public void writeDescriptionOn(BufferedWriter writer) throws IOException

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

INTERNAL: called from SQLSelectStatement.writeFieldsFromExpression(...) This allows a sub query in the select clause.

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

Overrides org.eclipse.persistence.expressions.Expression.writeSubexpressionsTo.

INTERNAL: Used in SQL printing.

Annotations
@Override