Methods Summary |
---|
public java.lang.String | descriptionOfNodeType()INTERNAL:
Used in debug printing of this node.
return "SubSelect";
|
public oracle.toplink.essentials.expressions.Expression | getBaseExpression()
return baseExpression;
|
public oracle.toplink.essentials.expressions.ExpressionBuilder | getBuilder()Return the builder from the defining expression.
return getBaseExpression().getBuilder();
|
public oracle.toplink.essentials.queryframework.ReportQuery | getSubQuery()
return subQuery;
|
public void | iterateOn(oracle.toplink.essentials.internal.expressions.ExpressionIterator iterator)INTERNAL:
For iterating using an inner class
super.iterateOn(iterator);
if (baseExpression != null) {
baseExpression.iterateOn(iterator);
}
// For Flashback: It is now possible to create iterators that will span
// the entire expression, even the where clause embedded in a subQuery.
if (iterator.shouldIterateOverSubSelects()) {
if (getSubQuery().getSelectionCriteria() != null) {
getSubQuery().getSelectionCriteria().iterateOn(iterator);
} else {
getSubQuery().getExpressionBuilder().iterateOn(iterator);
}
}
|
public oracle.toplink.essentials.expressions.Expression | normalize(oracle.toplink.essentials.internal.expressions.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.
//has no effect but validateNode is here for consistency
validateNode();
// Defer normalization of this expression until later.
normalizer.addSubSelectExpression(this);
normalizer.getStatement().setRequiresAliases(true);
return this;
|
public oracle.toplink.essentials.expressions.Expression | normalizeSubSelect(oracle.toplink.essentials.internal.expressions.ExpressionNormalizer normalizer, java.util.Dictionary clonedExpressions)INTERNAL:
Normalize this expression now that the parent statment has been normalized.
For CR#4223
// Anonymous subqueries: The following is to support sub-queries created
// on the fly by OSQL Expressions isEmpty(), isNotEmpty(), size().
if (!getSubQuery().isCallQuery() && (getSubQuery().getReferenceClass() == null)) {
ReportQuery subQuery = getSubQuery();
Expression criteria = subQuery.getSelectionCriteria();
// The criteria should be of form builder.equal(exp), where exp belongs
// to the parent statement and has already been normalized, hence it
// knows its reference class.
if (criteria instanceof LogicalExpression) {
criteria = ((LogicalExpression)criteria).getFirstChild();
}
if (criteria instanceof RelationExpression) {
Expression rightChild = ((RelationExpression)criteria).getSecondChild();
if (rightChild instanceof QueryKeyExpression) {
subQuery.setReferenceClass(((QueryKeyExpression)rightChild).getDescriptor().getJavaClass());
}
}
}
//has no effect but validateNode is here for consistency
validateNode();
getSubQuery().prepareSubSelect(normalizer.getSession(), null, clonedExpressions);
if (!getSubQuery().isCallQuery()) {
SQLSelectStatement statement = (SQLSelectStatement)((StatementQueryMechanism)getSubQuery().getQueryMechanism()).getSQLStatement();
// setRequiresAliases was already set for parent statement.
statement.setRequiresAliases(true);
statement.setParentStatement(normalizer.getStatement());
statement.normalize(normalizer.getSession(), getSubQuery().getDescriptor(), clonedExpressions);
}
return this;
|
protected void | postCopyIn(java.util.Dictionary alreadyDone)The query must be cloned, and the sub-expression must be cloned using the same outer expression identity.
super.postCopyIn(alreadyDone);
setBaseExpression(getBaseExpression().copiedVersionFrom(alreadyDone));
ReportQuery clonedQuery = (ReportQuery)getSubQuery().clone();
if ((!clonedQuery.isCallQuery()) && (clonedQuery.getSelectionCriteria() != null)) {
clonedQuery.setSelectionCriteria(getSubQuery().getSelectionCriteria().copiedVersionFrom(alreadyDone));
// If we are building/cloning a selection criteria for a batch query, a little extra work
// needs to be done (see bug 2812185).
if (alreadyDone.get(alreadyDone) != null) {
clonedQuery.copyReportItems(alreadyDone);
}
}
setSubQuery(clonedQuery);
|
protected void | printCustomSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)Print the sub query to the printer.
/*
* modified for bug#2658466. This fix ensures that Custom SQL sub-queries are translated
* and have variables substituted with values correctly.
*/
SQLCall call = (SQLCall)getSubQuery().getCall();
call.translateCustomQuery();
printer.getCall().getParameters().addAll(call.getParameters());
printer.getCall().getParameterTypes().addAll(call.getParameterTypes());
printer.printString(call.getCallString());
|
public void | printSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)Print the sub query to the printer.
ReportQuery query = getSubQuery();
printer.printString("(");
if (query.isCallQuery()) {
printCustomSQL(printer);
} else {
SQLSelectStatement statement = (SQLSelectStatement)((ExpressionQueryMechanism)query.getQueryMechanism()).getSQLStatement();
boolean isFirstElementPrinted = printer.isFirstElementPrinted();
printer.setIsFirstElementPrinted(false);
boolean requiresDistinct = printer.requiresDistinct();
statement.printSQL(printer);
printer.setIsFirstElementPrinted(isFirstElementPrinted);
printer.setRequiresDistinct(requiresDistinct);
}
printer.printString(")");
|
public oracle.toplink.essentials.expressions.Expression | rebuildOn(oracle.toplink.essentials.expressions.Expression newBase)Should not rebuild as has its on expression builder.
return this;
|
protected void | setBaseExpression(oracle.toplink.essentials.expressions.Expression baseExpression)
this.baseExpression = baseExpression;
|
public void | setSubQuery(oracle.toplink.essentials.queryframework.ReportQuery subQuery)
this.subQuery = subQuery;
|
public void | writeDescriptionOn(java.io.BufferedWriter writer)INTERNAL:
Used to print a debug form of the expression tree.
writer.write(String.valueOf(getSubQuery()));
|
public void | writeSubexpressionsTo(java.io.BufferedWriter writer, int indent)INTERNAL:
Used in SQL printing.
if (getSubQuery().getSelectionCriteria() != null) {
getSubQuery().getSelectionCriteria().toString(writer, indent);
}
|