SolarMetric Kodo JDO 3.1.6 generated on August 25 2004

kodo.jdbc.sql
Class Select

java.lang.Object
  |
  +--kodo.jdbc.sql.Select

public class Select
extends Object

Abstraction of a SQL SELECT statement.


Field Summary
static int BATCH_INNER
          Constant indicating to batch the select using an inner join.
static int BATCH_OUTER
          Constant indicating to batch the select using an outer join.
static int BATCH_SELECT
          Constant indicating to batch the select using a separate select.
static int SUBS_ANY
          Constant indicating to select subclasses but without adding any class conditions to the select.
static int SUBS_EXACT
          Constant indicating to select this class but without adding any class conditions to the select.
static int SUBS_FALSE
          Constant indicating to add conditions to the select to select this class only.
static int SUBS_TRUE
          Constant indicating to add conditions to the selcet to select this class and subclasses only.
 
Constructor Summary
Select(JDBCConfiguration conf)
          Constructor.
 
Method Summary
 void addBatchedType(ClassMapping type)
          Record that this select is for vrow columns of the given type.
 void addJoins(SQLBuffer buf, Joins joins)
          Add SQL for the given joins to the given buffer.
 Joins and(Joins joins1, Joins joins2)
          AND the given joins together.
 Select batchSelect(Object key, ClassMapping mapping, int batchType)
          Return SELECT that will be batched with this one, or null if the select cannot be batched for the given mapping and join type.
 void clearSelects()
          Clears any selected columns or aggregates.
 Collection getBatchedKeys()
          Return the set of batched select keys.
 Select getBatchedSelect(Object key)
          Return the batched select for the given key, or null if none.
 JDBCConfiguration getConfiguration()
          Return the configuration supplied on construction.
 Joins getJoins()
          Return the joins on this select.
 int getJoinSyntax()
          The join syntax for this select, as one of the syntax constants from Join.
 List getOrderings()
          Return a collection of orderings on this statement.
 int getResultSetConcurrency()
          The result set concurrency, such as ResultSet.CONCUR_READ_ONLY, or -1 for the default.
 int getResultSetType(boolean forUpdate)
          The result set type, such as ResultSet.TYPE_FORWARD_ONLY, or -1 for the default.
 List getSelectAliases()
          Return the aliases of all selected columns and all selected buffers, in the order they were selected.
 Collection getSelectedTableAliases()
          Return the set of selected table aliases.
 Collection getSelectedTables()
          Return the set of selected tables.
 List getSelects()
          Return all selected columns and buffer ids, in the order they were selected.
 SQLBuffer getWhere()
          Return the WHERE clause, minus any necessary end joins.
 boolean isAggregate()
          Return true if this is an aggregate select.
 boolean isDistinct()
          Return true if this is a SELECT DISTINCT.
 Select joinsSelect()
          Return a SELECT with the same aliases as this one.
 Joins newJoins()
          Return a new instance to use for joining.
 Joins or(Joins joins1, Joins joins2)
          OR the given joins together.
 void orderBy(Column[] cols, boolean ascending)
          Add an ORDER BY clause.
 void orderBy(Column[] cols, boolean ascending, Joins joins)
          Add an ORDER BY clause.
 void orderBy(Column col, boolean ascending)
          Add an ORDER BY clause.
 void orderBy(Column col, boolean ascending, Joins joins)
          Add an ORDER BY clause.
 void orderBy(SQLBuffer sql, boolean ascending)
          Add an ORDER BY clause.
 void orderBy(SQLBuffer sql, boolean ascending, Joins joins)
          Add an ORDER BY clause.
 Joins outer(Joins joins)
          Return a join set making the given joins outer joins.
 String reserveTableAlias(Table table)
          Reserve the next alias for the given table.
 void select(ClassMapping mapping, int subclasses, JDBCStoreManager store, JDBCFetchConfiguration fetch, int batch)
          Select the columns of the given mapping, possibly including subclasses.
 void select(ClassMapping mapping, int subclasses, JDBCStoreManager store, JDBCFetchConfiguration fetch, int batch, Joins joins)
          Select the columns of the given mapping, possibly including subclasses.
 void select(Column col)
          Select the given column.
 void select(Column[] cols)
          Select the given columns.
 void select(Column[] cols, Joins joins)
          Select the given columns.
 void select(Column col, Joins joins)
          Select the given column.
 void select(SQLBuffer buf, Object id)
          Select the given buffer; the given id object is an identifier to use when retrieving the corresponding value from a Result.
 void select(SQLBuffer buf, Object id, Joins joins)
          Select the given buffer; the given id object is an identifier to use when retrieving the corresponding value from a Result.
 void selectPrimaryKey(ClassMapping mapping)
          Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.
 void selectPrimaryKey(ClassMapping mapping, Joins joins)
          Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.
 void setAggregate(boolean agg)
          Set to true for aggregate selects.
 void setJoinSyntax(int joinSyntax)
          The join syntax for this select, as one of the syntax constants from Join.
 void setResultSetConcurrency(int concur)
          The result set concurrency, such as ResultSet.CONCUR_READ_ONLY, or -1 for the default.
 void setResultSetType(int type)
          The result set type, such as ResultSet.TYPE_FORWARD_ONLY, or -1 for the default.
 Select subSelect(Joins parentJoins)
          Return a subselect of this one.
 SQLBuffer toSelect(boolean forUpdate)
          Return this select as a SQL statement formatted for the given dictionary.
 SQLBuffer toSelectCount()
          Return this select as a COUNT SQL statement formatted for the given dictionary.
 String toString()
          Implement toString to generate SQL string for profiling/debuggging.
 void where(Joins joins)
          Add the given where conditions.
 void where(SQLBuffer sql)
          Add the given where conditions.
 void where(SQLBuffer sql, Joins joins)
          Add the given where conditions.
 void whereForeignKey(ForeignKey fk, Object oid, ClassMapping mapping)
          Add where conditions setting the given foreign key to the given oid values.
 void whereForeignKey(ForeignKey fk, Object oid, ClassMapping mapping, Joins joins)
          Add where conditions setting the given foreign key to the given oid values.
 void wherePrimaryKey(Object oid, ClassMapping mapping)
          Add where conditions setting the mapping's primary key to the given oid values.
 void wherePrimaryKey(Object oid, ClassMapping mapping, Joins joins)
          Add where conditions setting the mapping's primary key to the given oid values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BATCH_INNER

public static final int BATCH_INNER
Constant indicating to batch the select using an inner join.

BATCH_OUTER

public static final int BATCH_OUTER
Constant indicating to batch the select using an outer join.

BATCH_SELECT

public static final int BATCH_SELECT
Constant indicating to batch the select using a separate select.

SUBS_TRUE

public static final int SUBS_TRUE
Constant indicating to add conditions to the selcet to select this class and subclasses only.

SUBS_FALSE

public static final int SUBS_FALSE
Constant indicating to add conditions to the select to select this class only.

SUBS_ANY

public static final int SUBS_ANY
Constant indicating to select subclasses but without adding any class conditions to the select.

SUBS_EXACT

public static final int SUBS_EXACT
Constant indicating to select this class but without adding any class conditions to the select.
Constructor Detail

Select

public Select(JDBCConfiguration conf)
Constructor. Supply configuration.
Method Detail

getConfiguration

public JDBCConfiguration getConfiguration()
Return the configuration supplied on construction.

toSelect

public SQLBuffer toSelect(boolean forUpdate)
Return this select as a SQL statement formatted for the given dictionary.

toSelectCount

public SQLBuffer toSelectCount()
Return this select as a COUNT SQL statement formatted for the given dictionary.

isDistinct

public boolean isDistinct()
Return true if this is a SELECT DISTINCT.

getSelectedTables

public Collection getSelectedTables()
Return the set of selected tables.

getSelectedTableAliases

public Collection getSelectedTableAliases()
Return the set of selected table aliases.

getSelects

public List getSelects()
Return all selected columns and buffer ids, in the order they were selected.

getSelectAliases

public List getSelectAliases()
Return the aliases of all selected columns and all selected buffers, in the order they were selected.

getOrderings

public List getOrderings()
Return a collection of orderings on this statement. Orderings always come in pairs: a SQLBuffer for the ordering criteria, and then a string for the order - "ASC" or "DESC".

getWhere

public SQLBuffer getWhere()
Return the WHERE clause, minus any necessary end joins.

getJoins

public Joins getJoins()
Return the joins on this select.

getResultSetType

public int getResultSetType(boolean forUpdate)
The result set type, such as ResultSet.TYPE_FORWARD_ONLY, or -1 for the default.

setResultSetType

public void setResultSetType(int type)
The result set type, such as ResultSet.TYPE_FORWARD_ONLY, or -1 for the default.

getResultSetConcurrency

public int getResultSetConcurrency()
The result set concurrency, such as ResultSet.CONCUR_READ_ONLY, or -1 for the default.

setResultSetConcurrency

public void setResultSetConcurrency(int concur)
The result set concurrency, such as ResultSet.CONCUR_READ_ONLY, or -1 for the default.

getJoinSyntax

public int getJoinSyntax()
The join syntax for this select, as one of the syntax constants from Join.

setJoinSyntax

public void setJoinSyntax(int joinSyntax)
The join syntax for this select, as one of the syntax constants from Join.

reserveTableAlias

public String reserveTableAlias(Table table)
Reserve the next alias for the given table. The table is not added to the table list, but the returned alias is reserved for it should any column of the table be selected later.

isAggregate

public boolean isAggregate()
Return true if this is an aggregate select.

setAggregate

public void setAggregate(boolean agg)
Set to true for aggregate selects.

select

public void select(SQLBuffer buf,
                   Object id)
Select the given buffer; the given id object is an identifier to use when retrieving the corresponding value from a Result.

select

public void select(SQLBuffer buf,
                   Object id,
                   Joins joins)
Select the given buffer; the given id object is an identifier to use when retrieving the corresponding value from a Result.

select

public void select(Column col)
Select the given column.

select

public void select(Column col,
                   Joins joins)
Select the given column.

select

public void select(Column[] cols)
Select the given columns.

select

public void select(Column[] cols,
                   Joins joins)
Select the given columns.

select

public void select(ClassMapping mapping,
                   int subclasses,
                   JDBCStoreManager store,
                   JDBCFetchConfiguration fetch,
                   int batch)
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects.

select

public void select(ClassMapping mapping,
                   int subclasses,
                   JDBCStoreManager store,
                   JDBCFetchConfiguration fetch,
                   int batch,
                   Joins joins)
Select the columns of the given mapping, possibly including subclasses. This method should be called after all where conditions are added in case the given mapping batches other selects.

clearSelects

public void clearSelects()
Clears any selected columns or aggregates. Does not modify WHERE clauses etc.

selectPrimaryKey

public void selectPrimaryKey(ClassMapping mapping)
Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.

selectPrimaryKey

public void selectPrimaryKey(ClassMapping mapping,
                             Joins joins)
Select the primary key columns of the given mapping, joining to superclasses as necessary to get all columns needed to construct an object id.

wherePrimaryKey

public void wherePrimaryKey(Object oid,
                            ClassMapping mapping)
Add where conditions setting the mapping's primary key to the given oid values. If the given mapping does not use oid values for its primary key, we will recursively join to its superclass until we find an ancestor that does.

wherePrimaryKey

public void wherePrimaryKey(Object oid,
                            ClassMapping mapping,
                            Joins joins)
Add where conditions setting the mapping's primary key to the given oid values. If the given mapping does not use oid values for its primary key, we will recursively join to its superclass until we find an ancestor that does.

whereForeignKey

public void whereForeignKey(ForeignKey fk,
                            Object oid,
                            ClassMapping mapping)
Add where conditions setting the given foreign key to the given oid values.
See Also:
wherePrimaryKey(java.lang.Object, kodo.jdbc.meta.ClassMapping)

whereForeignKey

public void whereForeignKey(ForeignKey fk,
                            Object oid,
                            ClassMapping mapping,
                            Joins joins)
Add where conditions setting the given foreign key to the given oid values.
See Also:
wherePrimaryKey(java.lang.Object, kodo.jdbc.meta.ClassMapping)

where

public void where(Joins joins)
Add the given where conditions.

where

public void where(SQLBuffer sql)
Add the given where conditions.

where

public void where(SQLBuffer sql,
                  Joins joins)
Add the given where conditions.

orderBy

public void orderBy(SQLBuffer sql,
                    boolean ascending)
Add an ORDER BY clause.

orderBy

public void orderBy(SQLBuffer sql,
                    boolean ascending,
                    Joins joins)
Add an ORDER BY clause.

orderBy

public void orderBy(Column col,
                    boolean ascending)
Add an ORDER BY clause.

orderBy

public void orderBy(Column col,
                    boolean ascending,
                    Joins joins)
Add an ORDER BY clause.

orderBy

public void orderBy(Column[] cols,
                    boolean ascending)
Add an ORDER BY clause.

orderBy

public void orderBy(Column[] cols,
                    boolean ascending,
                    Joins joins)
Add an ORDER BY clause.

subSelect

public Select subSelect(Joins parentJoins)
Return a subselect of this one.

joinsSelect

public Select joinsSelect()
Return a SELECT with the same aliases as this one.

getBatchedSelect

public Select getBatchedSelect(Object key)
Return the batched select for the given key, or null if none.

getBatchedKeys

public Collection getBatchedKeys()
Return the set of batched select keys.

batchSelect

public Select batchSelect(Object key,
                          ClassMapping mapping,
                          int batchType)
Return SELECT that will be batched with this one, or null if the select cannot be batched for the given mapping and join type. If the join type is inner or outer, then this select instance will be returned. Otherwise, the returned select will have a clone of this select's where conditions and joins but will be independent.
Parameters:
key - the key for the batched select
mapping - the type the select is batching
batchType - BATCH_INNER, BATCH_OUTER, or BATCH_SELECT

addBatchedType

public void addBatchedType(ClassMapping type)
Record that this select is for vrow columns of the given type.

newJoins

public Joins newJoins()
Return a new instance to use for joining.

addJoins

public void addJoins(SQLBuffer buf,
                     Joins joins)
Add SQL for the given joins to the given buffer.

and

public Joins and(Joins joins1,
                 Joins joins2)
AND the given joins together. The given joins will be hollowed in the process.

or

public Joins or(Joins joins1,
                Joins joins2)
OR the given joins together. The common joins will be removed in the process.

outer

public Joins outer(Joins joins)
Return a join set making the given joins outer joins.

toString

public String toString()
Implement toString to generate SQL string for profiling/debuggging.
Overrides:
toString in class Object

SolarMetric Kodo JDO 3.1.6 generated on August 25 2004

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.