wt.pds
Class SelectStatementBuilder

java.lang.Object
  extended bywt.pds.BasicStatementBuilder
      extended bywt.pds.SelectStatementBuilder
All Implemented Interfaces:
Externalizable, Serializable, StatementBuilder
Direct Known Subclasses:
QuerySpecStatementBuilder

public abstract class SelectStatementBuilder
extends BasicStatementBuilder
implements Externalizable

This class builds a select statements for the given classes.

Supported API: false

Extendable: false

See Also:
Serialized Form

Field Summary
protected  int chunkCount
           
private static String CLASSNAME
           
static boolean DEBUG
           
private  Integer depthThreshold
           
static long EXTERNALIZATION_VERSION_UID
           
protected static String LARGE_IN_LIST_WARNING
           
private static DebugWriter LOG
           
protected static long OLD_FORMAT_VERSION_UID
           
protected static long OLD_SERIAL_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
private  int totalCount
           
private  boolean unionStatement
           
 
Fields inherited from class wt.pds.BasicStatementBuilder
DMLGENERATOR
 
Fields inherited from interface wt.pds.StatementBuilder
CHUNKING_ENABLED, FETCH_SIZE, SQL_STATEMENTS, STATEMENT_COUNT
 
Constructor Summary
SelectStatementBuilder()
           
 
Method Summary
abstract  String buildEmptyAggregateSQL()
          

Supported API: false
 String[] buildSQL(ResultBuilder a_resultBuilder, WTConnection a_connection, boolean a_isComponent, boolean a_isComponentChunkSupported)
          Returns an array of JDBC statements to execute.
abstract  String buildSQLStatement(Vector a_tables, Vector a_aliases, ResultBuilder a_resultBuilder, boolean a_distinct, WhereClause a_whereClause, String a_orderByClause, GroupByClause a_groupByClause, ConditionsClause a_havingClause, int a_sqlIndex, boolean a_forUpdate)
          This method builds a SQL statement.
protected  void clone(SelectStatementBuilder clone)
          This method is a clone "helper".
protected abstract  List getArrayChunkProcessors(int a_arraySizeThreshold)
          This method returns a List of ArrayChunkProcessor instances for this query.
protected  int getChunkProcessorCount()
           
protected  int getChunkProcessorCount(int chunkProcessorLimit)
           
 Integer getDepthThreshold()
          Gets the value of the attribute: depthThreshold; Threshold value for the number of subclass combinations.
abstract  FromClause getFromClause()
          Gets the object for the association that plays role: fromClause.
abstract  GroupByClause getGroupByClause()
          Gets the value of the attribute: groupByClause.
abstract  ConditionsClause getHavingClause()
          Gets the value of the attribute: havingClause.
abstract  OrderByClause getOrderByClause()
          Gets the value of the attribute: orderByClause.
abstract  StatementFilter getStatementFilter(Vector[] a_fromArray)
          StatementBuilder used to generate SQL for the depth threshold query.
abstract  Vector[] getTables()
          This method returns an array of Vectors.
protected  int getTotalCount()
          Gets the value of the attribute: totalCount; Total number of SQL statements.
abstract  WhereClause getWhereClause()
          Gets the value of the attribute: whereClause.
abstract  boolean isAggregateSelect()
          

Supported API: false
abstract  boolean isDistinct()
          Gets the value of the attribute: distinct.
 boolean isForUpdateSet()
          Gets the value of the attribute: forUpdateSet.
protected  boolean isQueryChunkingRequired()
           
protected  boolean isQueryChunkingRequired(int chunkProcessorLimit)
           
protected  boolean isQueryChunkingSupported()
           
abstract  boolean isQuerySpecSetLock()
          

Supported API: false
protected  boolean isUnionStatement()
          Gets the value of the attribute: unionStatement; Indicates if a union statement is used.
abstract  boolean isUseBind()
          Gets the value of the attribute: useBind.
abstract  List preBuildSQL()
          This method is used to process join search conditions, construct bind parameters for the Where, and set class view attributes.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(SelectStatementBuilder thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
protected abstract  void resetBindParameterVectors()
           
 void setDepthThreshold(Integer a_DepthThreshold)
          Sets the value of the attribute: depthThreshold; Threshold value for the number of subclass combinations.
 void setForUpdateSet(boolean a_ForUpdateSet)
          Sets the value of the attribute: forUpdateSet.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class wt.pds.BasicStatementBuilder
appendBindParameter, buildSQL, clone, getFetchSize, getSqlStatements, getStatement, getStatementBindParameters, getStatementCount, insertBindParameterAt, isChunkingEnabled, readVersion, setChunkingEnabled, setFetchSize, setSqlStatements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

depthThreshold

private Integer depthThreshold

totalCount

private transient int totalCount

unionStatement

private transient boolean unionStatement

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

OLD_SERIAL_VERSION_UID

protected static final long OLD_SERIAL_VERSION_UID
See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG

LOG

private static final DebugWriter LOG

chunkCount

protected transient int chunkCount

LARGE_IN_LIST_WARNING

protected static final String LARGE_IN_LIST_WARNING
See Also:
Constant Field Values
Constructor Detail

SelectStatementBuilder

public SelectStatementBuilder()
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class BasicStatementBuilder
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class BasicStatementBuilder
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(SelectStatementBuilder thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

isDistinct

public abstract boolean isDistinct()
Gets the value of the attribute: distinct.

Supported API: false

Returns:
boolean

getWhereClause

public abstract WhereClause getWhereClause()
Gets the value of the attribute: whereClause.

Supported API: false

Returns:
WhereClause

getOrderByClause

public abstract OrderByClause getOrderByClause()
                                        throws WTException
Gets the value of the attribute: orderByClause.

Supported API: false

Returns:
OrderByClause
Throws:
WTException

getDepthThreshold

public Integer getDepthThreshold()
Gets the value of the attribute: depthThreshold; Threshold value for the number of subclass combinations. Once this threshold is reached, a UNION statement is executed to determine which of the subclass combinations contains data that will need to be retrieved. A null value indicates that the DBProperties setting should be used.

Supported API: false

Returns:
Integer

setDepthThreshold

public void setDepthThreshold(Integer a_DepthThreshold)
                       throws WTPropertyVetoException
Sets the value of the attribute: depthThreshold; Threshold value for the number of subclass combinations. Once this threshold is reached, a UNION statement is executed to determine which of the subclass combinations contains data that will need to be retrieved. A null value indicates that the DBProperties setting should be used.

Supported API: false

Parameters:
a_DepthThreshold -
Throws:
WTPropertyVetoException

getGroupByClause

public abstract GroupByClause getGroupByClause()
                                        throws WTException
Gets the value of the attribute: groupByClause.

Supported API: false

Returns:
GroupByClause
Throws:
WTException

getTotalCount

protected int getTotalCount()
Gets the value of the attribute: totalCount; Total number of SQL statements. Valid only after call to buildSQL().

Supported API: false

Returns:
int

isUnionStatement

protected boolean isUnionStatement()
Gets the value of the attribute: unionStatement; Indicates if a union statement is used. Valid only after call to buildSQL().

Supported API: false

Returns:
boolean

isUseBind

public abstract boolean isUseBind()
Gets the value of the attribute: useBind.

Supported API: false

Returns:
boolean

getHavingClause

public abstract ConditionsClause getHavingClause()
                                          throws WTException
Gets the value of the attribute: havingClause.

Supported API: false

Returns:
ConditionsClause
Throws:
WTException

isForUpdateSet

public boolean isForUpdateSet()
Gets the value of the attribute: forUpdateSet.

Supported API: false

Returns:
boolean

setForUpdateSet

public void setForUpdateSet(boolean a_ForUpdateSet)
                     throws WTPropertyVetoException
Sets the value of the attribute: forUpdateSet.

Supported API: false

Parameters:
a_ForUpdateSet -
Throws:
WTPropertyVetoException

getFromClause

public abstract FromClause getFromClause()
Gets the object for the association that plays role: fromClause.

Supported API: false

Returns:
FromClause

buildSQL

public String[] buildSQL(ResultBuilder a_resultBuilder,
                         WTConnection a_connection,
                         boolean a_isComponent,
                         boolean a_isComponentChunkSupported)
                  throws PersistenceException
Returns an array of JDBC statements to execute.

Supported API: false

Specified by:
buildSQL in interface StatementBuilder
Parameters:
a_resultBuilder -
a_connection -
a_isComponent - Indicates that these SQL statements will be used as nested components of another SQL statement.
a_isComponentChunkSupported - Indicates that these SQL statements will support chunk or not, and the value will be false when a_isComponent is false, and can be true or false when a_isComponents is true.
Returns:
String[]
Throws:
PersistenceException

getTables

public abstract Vector[] getTables()
                            throws PersistenceException
This method returns an array of Vectors. Each element of the array corresponds to the TableExpression at the corresponding position in the FromClause. The elements are all possible combinations of concrete TableExpressions that need to be queried.

Supported API: false

Returns:
Vector[]
Throws:
PersistenceException

buildSQLStatement

public abstract String buildSQLStatement(Vector a_tables,
                                         Vector a_aliases,
                                         ResultBuilder a_resultBuilder,
                                         boolean a_distinct,
                                         WhereClause a_whereClause,
                                         String a_orderByClause,
                                         GroupByClause a_groupByClause,
                                         ConditionsClause a_havingClause,
                                         int a_sqlIndex,
                                         boolean a_forUpdate)
                                  throws PersistenceException
This method builds a SQL statement.

Supported API: false

Parameters:
a_tables - The TableExpressions for this statement.
a_aliases - The aliases corresponding to the TableExpressions for this statement.
a_resultBuilder - Result builder instance to use for constructing the statement.
a_distinct -
a_whereClause -
a_orderByClause -
a_groupByClause -
a_havingClause -
a_sqlIndex - SQL index of this statement.
a_forUpdate -
Returns:
String
Throws:
PersistenceException

getStatementFilter

public abstract StatementFilter getStatementFilter(Vector[] a_fromArray)
                                            throws PersistenceException
StatementBuilder used to generate SQL for the depth threshold query.

Supported API: false

Parameters:
a_fromArray - Array of Vectors containing FromExpression instances
Returns:
StatementFilter
Throws:
PersistenceException

buildEmptyAggregateSQL

public abstract String buildEmptyAggregateSQL()
                                       throws PersistenceException


Supported API: false

Returns:
String
Throws:
PersistenceException

isAggregateSelect

public abstract boolean isAggregateSelect()


Supported API: false

Returns:
boolean

isQuerySpecSetLock

public abstract boolean isQuerySpecSetLock()


Supported API: false

Returns:
boolean

preBuildSQL

public abstract List preBuildSQL()
                          throws PersistenceException
This method is used to process join search conditions, construct bind parameters for the Where, and set class view attributes.

Supported API: false

Returns:
List
Throws:
PersistenceException

getArrayChunkProcessors

protected abstract List getArrayChunkProcessors(int a_arraySizeThreshold)
                                         throws WTException
This method returns a List of ArrayChunkProcessor instances for this query.

Throws:
WTException

clone

protected void clone(SelectStatementBuilder clone)
This method is a clone "helper". It calls the super class clone "helper" and then clones the attributes at this level in the hierarchy.

Parameters:
clone - pre-allocated object to clone

isQueryChunkingSupported

protected boolean isQueryChunkingSupported()
                                    throws WTException
Throws:
WTException

getChunkProcessorCount

protected int getChunkProcessorCount()
                              throws WTException
Throws:
WTException

isQueryChunkingRequired

protected boolean isQueryChunkingRequired()
                                   throws WTException
Throws:
WTException

getChunkProcessorCount

protected int getChunkProcessorCount(int chunkProcessorLimit)
                              throws WTException
Throws:
WTException

isQueryChunkingRequired

protected boolean isQueryChunkingRequired(int chunkProcessorLimit)
                                   throws WTException
Throws:
WTException

resetBindParameterVectors

protected abstract void resetBindParameterVectors()