Class SelectQueryPlan
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.QueryPlan
-
- com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.SelectQueryPlan
-
- Direct Known Subclasses:
CorrelatedSelectPlan
,VerificationSelectPlan
public class SelectQueryPlan extends QueryPlan
This class prepares the generation of select statements, by joining the constaint stacks of all retrieve descriptors into one stack.
-
-
Field Summary
Fields Modifier and Type Field Description protected Constraint
constraint
Pointer to the retrieve descriptor's constraint stack.static String
MULTILEVEL_PREFETCH_PROPERTY
Name of the MULTILEVEL_PREFETCH property.int
options
Bitmask constaining OPT_* Constants defined inRetrieveDescImpl
protected ForeignFieldDesc
parentField
This foreign field joins this plan to the parent plan.static int
ST_C_BUILT
This plans's constraints are already processed.static int
ST_OC_BUILT
This plans's order by constraints are already processed.-
Fields inherited from class com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.QueryPlan
ACT_DELETE, ACT_INSERT, ACT_NOOP, ACT_SELECT, ACT_UPDATE, action, config, messages, ST_BUILT, statements, status, store, tables
-
-
Constructor Summary
Constructors Constructor Description SelectQueryPlan(ActionDesc desc, SQLStoreManager store, Concurrency concurrency)
Creates a new SelectQueryPlan.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addColumn(LocalFieldDesc fieldDesc)
The addColumn method is used to specify a field for which data needs to be retrieved and therefore for which we need to select a column.protected void
addJoinConstraint(SelectQueryPlan fromPlan, SelectQueryPlan toPlan, ArrayList fromColumns, ArrayList toColumns, int joinOp)
Put in a join constraint to the foreign table.protected void
addTable(LocalFieldDesc fieldDesc)
The addTable method is used to add tables correponding to a field to the plan.void
build()
Builds the query plan for a select typeActionDesc
(i.e.Constraint
getConstraint()
Object
getResult(PersistenceManager pm, ResultSet resultData)
Extract data from givenresultData
static SelectQueryPlan
newInstance(RetrieveDescImpl desc, SQLStoreManager store, Concurrency concurrency)
Creates a new instance of SelectQueryPlan depending on the retrieve descriptor options.protected Statement
newStatement()
protected void
processConstraints()
protected void
processFields()
Process the fields from the retrieve descriptor's field list.void
processOrderConstraints()
Converts ConstraintFieldName used in Order by constraints into ConstraintFieldDesc using ConstraintFieldName#originalPlan.
Currently unused functionality:
Gets all the "order by" constraints from the the current stack.protected void
processStatements()
This method goes through the statement list and tries to set up relationship between statements based on secondary table keys.-
Methods inherited from class com.sun.jdo.spi.persistence.support.sqlstore.sql.generator.QueryPlan
addQueryTable, addQueryTable, addQueryTables, addStatement, createStatement, findQueryTable, findQueryTable, getAction, getConfig, getStatement, getStatements
-
-
-
-
Field Detail
-
ST_C_BUILT
public static final int ST_C_BUILT
This plans's constraints are already processed.- See Also:
- Constant Field Values
-
ST_OC_BUILT
public static final int ST_OC_BUILT
This plans's order by constraints are already processed.- See Also:
- Constant Field Values
-
constraint
protected Constraint constraint
Pointer to the retrieve descriptor's constraint stack. NOTE: The retrieve descriptor's stack will be modified building the query plan!
-
options
public int options
Bitmask constaining OPT_* Constants defined inRetrieveDescImpl
-
parentField
protected ForeignFieldDesc parentField
This foreign field joins this plan to the parent plan. The field is from config of the parent plan. Used only for dependent plan.
-
MULTILEVEL_PREFETCH_PROPERTY
public static final String MULTILEVEL_PREFETCH_PROPERTY
Name of the MULTILEVEL_PREFETCH property.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SelectQueryPlan
public SelectQueryPlan(ActionDesc desc, SQLStoreManager store, Concurrency concurrency)
Creates a new SelectQueryPlan.- Parameters:
desc
- Retrieve descriptor holding the query information from the query compiler. This information includes selected fields and the query constraints.desc
must be an instance of RetrieveDescImpl.store
- Store manager executing the query.concurrency
- Query concurrency.
-
-
Method Detail
-
newInstance
public static SelectQueryPlan newInstance(RetrieveDescImpl desc, SQLStoreManager store, Concurrency concurrency)
Creates a new instance of SelectQueryPlan depending on the retrieve descriptor options.- Parameters:
desc
- The retrieve descriptorstore
- The storeconcurrency
- The concurrency for the plan.- Returns:
- An instance of SelectQueryPlan depending on the retrieve descriptor options.
-
getConstraint
public Constraint getConstraint()
-
addTable
protected void addTable(LocalFieldDesc fieldDesc)
The addTable method is used to add tables correponding to a field to the plan. No columns corresponding the field are added to the plan.- Parameters:
fieldDesc
- The field for which we need to add table
-
addColumn
protected void addColumn(LocalFieldDesc fieldDesc)
The addColumn method is used to specify a field for which data needs to be retrieved and therefore for which we need to select a column.- Parameters:
fieldDesc
- The field for which we need to retrieve data and therefore for which we need to select a column.
-
processStatements
protected void processStatements()
Description copied from class:QueryPlan
This method goes through the statement list and tries to set up relationship between statements based on secondary table keys.- Overrides:
processStatements
in classQueryPlan
-
build
public void build()
Builds the query plan for a select typeActionDesc
(i.e. aRetrieveDesc
).
-
processFields
protected void processFields()
Process the fields from the retrieve descriptor's field list. Must be overwritten by subquery plans!
-
processConstraints
protected void processConstraints()
-
addJoinConstraint
protected void addJoinConstraint(SelectQueryPlan fromPlan, SelectQueryPlan toPlan, ArrayList fromColumns, ArrayList toColumns, int joinOp)
Put in a join constraint to the foreign table.- Parameters:
fromPlan
- The plan for fromColumnstoPlan
- The plan for toColumnsfromColumns
- List of local columns.toColumns
- List of foreign columns.joinOp
- Join operation. This operation is never a non relationship join.
-
processOrderConstraints
public void processOrderConstraints()
Converts ConstraintFieldName used in Order by constraints into ConstraintFieldDesc using ConstraintFieldName#originalPlan.
Currently unused functionality:
Gets all the "order by" constraints from the the current stack. The constraints are ordered such that any "order by" constraint with position N is placed before any "order by" constraint with position N+m, where m > 0. Also any "order by" constraint with no position (i.e. position < 0) are placed immediately following the previous "order by" constraint with a position. The order of the "order by" constraints on the constraint stack is changed to effect this ordering. NOTE: The value constraints giving the position for the order by constraints is currently not generated by the query compiler.
-
newStatement
protected Statement newStatement()
- Specified by:
newStatement
in classQueryPlan
-
getResult
public Object getResult(PersistenceManager pm, ResultSet resultData) throws SQLException
Extract data from givenresultData
- Parameters:
pm
- The PersistenceManager.resultData
- The result set from which data is to be extracted.- Returns:
- Result from the given
resultData
- Throws:
SQLException
-
-