Class SelectStatement
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.Statement
-
- com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.SelectStatement
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
SelectOneStatement
public class SelectStatement extends Statement
This class generates select statements.
-
-
Field Summary
-
Fields inherited from class com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.Statement
columns, inputDesc, messages, OP_BINOP_MASK, OP_FUNC_MASK, OP_INFIX_MASK, OP_IRREGULAR_MASK, OP_ORDERBY_MASK, OP_OTHER_MASK, OP_PARAM_MASK, OP_PAREN_MASK, OP_PCOUNT_MASK, OP_POSTFIX_MASK, OP_PREFIX_MASK, OP_WHERE_MASK, secondaryTableStatements, statementText, tableList, vendorType
-
-
Constructor Summary
Constructors Constructor Description SelectStatement(DBVendorType vendorType, SelectQueryPlan plan)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnRef
addColumn(org.netbeans.modules.dbschema.ColumnElement columnElement, QueryTable queryTable)
void
appendTableText(StringBuilder text, QueryTable table)
void
bindInputValues(DBStatement s, ValueFetcher parameters)
Binds input valus corrsponding to thisStatement
object to database statement s.void
copyColumns(SelectStatement sourceStatement)
protected StringBuilder
generateColumnText()
protected void
generateStatementText()
Generates the SQL text for the query described by this object.String
getFormattedSQLText(ValueFetcher parameters)
Gets formatted sql text corrsponding to this statement object.protected String
getJoinOperator(int operation)
Returns join operator for specified operation.QueryPlan
getQueryPlan()
Get QueryPlan for this statementboolean
isColumnTypeDefinitionNeeded()
Determines if Column Type definition is needed for this statement.boolean
isJoined()
protected boolean
isUpdateLockRequired(QueryTable table)
void
markJoined()
protected void
processIrregularOperation(ConstraintOperation opNode, int opCode, List stack, StringBuilder result)
protected void
processRootConstraint(ConstraintOperation opNode, List stack, StringBuilder whereText)
Processes Order By constraints and calls the super class method for all other constrains.-
Methods inherited from class com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.Statement
addColumnRef, addConstraint, addQueryTable, addSecondaryTableStatement, appendQuotedText, bindInputValues, clone, findQueryTable, formatSqlText, generateColumnText, generateInputValueForConstraintValueNode, getAction, getColumnRef, getColumnRefs, getFormattedSQLText, getOriginalPlan, getQueryTables, getSecondaryTableStatements, getText, getVendorType, getWhereText, infixOperator, operationFormat, postfixOperator, prefixOperator, processConstraintParamIndex, processConstraints, processConstraintValue, setAction
-
-
-
-
Constructor Detail
-
SelectStatement
public SelectStatement(DBVendorType vendorType, SelectQueryPlan plan)
-
-
Method Detail
-
isJoined
public boolean isJoined()
-
markJoined
public void markJoined()
-
addColumn
public ColumnRef addColumn(org.netbeans.modules.dbschema.ColumnElement columnElement, QueryTable queryTable)
-
copyColumns
public void copyColumns(SelectStatement sourceStatement)
-
isUpdateLockRequired
protected boolean isUpdateLockRequired(QueryTable table)
-
appendTableText
public void appendTableText(StringBuilder text, QueryTable table)
- Overrides:
appendTableText
in classStatement
-
isColumnTypeDefinitionNeeded
public boolean isColumnTypeDefinitionNeeded()
Determines if Column Type definition is needed for this statement. Column Type definition is a performance optimization that allows defining Column Type for the resultset. If the query to be executed is counting pc instances, the column used inside COUNT() is one of the pk columns. If the pk column happens to be not convertable to an int (for example timestamp), database will throw an exception. To prevent this situation, column type definition should not be performed on such queries.- Returns:
- true if column type definition is needed, false otherwise.
-
getQueryPlan
public QueryPlan getQueryPlan()
Description copied from class:Statement
Get QueryPlan for this statement- Specified by:
getQueryPlan
in classStatement
- Returns:
- QueryPlan for this statement
-
generateStatementText
protected void generateStatementText()
Description copied from class:Statement
Generates the SQL text for the query described by this object.- Specified by:
generateStatementText
in classStatement
-
generateColumnText
protected StringBuilder generateColumnText()
-
processRootConstraint
protected void processRootConstraint(ConstraintOperation opNode, List stack, StringBuilder whereText)
Processes Order By constraints and calls the super class method for all other constrains.- Overrides:
processRootConstraint
in classStatement
-
processIrregularOperation
protected void processIrregularOperation(ConstraintOperation opNode, int opCode, List stack, StringBuilder result)
- Overrides:
processIrregularOperation
in classStatement
-
getJoinOperator
protected String getJoinOperator(int operation)
Returns join operator for specified operation.- Parameters:
operation
- The join operation. Should be one of ActionDesc.OP_EQUIJOIN, ActionDesc.OP_LEFTJOIN or ActionDesc.OP_RIGHTJOIN.- Returns:
- join operator for specified operation.
-
bindInputValues
public void bindInputValues(DBStatement s, ValueFetcher parameters) throws SQLException
Binds input valus corrsponding to thisStatement
object to database statement s.- Parameters:
s
- The database statement.parameters
- If an InputValue to be bound is a parameter, the actual value is contained in this.- Throws:
SQLException
-
getFormattedSQLText
public String getFormattedSQLText(ValueFetcher parameters)
Gets formatted sql text corrsponding to this statement object. The text also contains values for input to the statement.- Parameters:
parameters
- The input paramters to this statement.- Returns:
- formatted sql text corrsponding to this statement object.
-
-