wt.query
Class CompoundQuerySpec

java.lang.Object
  extended bywt.query.CompoundQuerySpec
All Implemented Interfaces:
Externalizable, Serializable, StatementSpec

public class CompoundQuerySpec
extends Object
implements StatementSpec, Externalizable

This class provides the functionality to build a compound query statement.

Any number of components can be added to the Compound Query (Two are required for a valid compound SQL statement). A single Set Operator can be specified.

The SQL statement is built from left to right using the components with the lowest index to the highest index. If precedence is significant, the components with equal precedence should be added to a separate instance and nested within another CompoundQuerySpec instance.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private  boolean advancedQueryEnabled
           
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
private  ResultBuilder resultBuilder
           
private  ResultCursor resultCursor
           
(package private) static long serialVersionUID
           
private  CompoundStatementBuilder statementBuilder
           
private  StatementSpec thePrimary
           
 
Fields inherited from interface wt.pds.StatementSpec
ADVANCED_QUERY, ADVANCED_QUERY_ENABLED, AGGREGATE_SELECT, CORRELATED_CLASS_ATTRIBUTES, FETCH_SIZE, PRIMARY_CLASS, QUERY_LIMIT, RESULT_BUILDER, RESULT_CURSOR, SINGLE_RESULT_COMPATIBLE, STATEMENT_BUILDER, USE_BIND
 
Constructor Summary
CompoundQuerySpec()
           
 
Method Summary
 void addComponent(StatementSpec a_statementSpec)
          This method adds a component statement.
 void appendOrderBy(OrderBy a_orderBy)
          Appends an Order By expression to the compund query.
private  int findMinimumLimit(Vector components)
           
private  StatementSpec findNonEmptyComponent()
           
 List getAllComponentQuerySpecs()
           
 List getAllComponentQuerySpecs(StatementSpec a_statementSpec, List a_querySpecs)
           
 int getBindParameterCount()
          

Supported API: false
 ArrayList getChunkableComponents()
          Return a list of components which contains a larget value list greater than a configurable limit.
 Vector getComponents()
          Gets the object for the association that plays role: components.
 List getCorrelatedClassAttributes()
          Gets the value of the attribute: correlatedClassAttributes.
 int getFetchSize()
          Gets the value of the attribute: fetchSize; A hint as to the number of rows that should be fetched from the database when more rows are needed.
private  StatementSpec getPrimary()
           
 Class getPrimaryClass()
          Gets the value of the attribute: primaryClass; Primary class for the query.
 int getQueryLimit()
          Gets the value of the attribute: queryLimit.
 ResultBuilder getResultBuilder()
          Gets the object for the association that plays role: resultBuilder.
 ResultCursor getResultCursor()
          Gets the object for the association that plays role: resultCursor.
 SetOperator getSetOperator()
          Gets the object for the association that plays role: setOperator.
 StatementBuilder getStatementBuilder()
          Gets the object for the association that plays role: statementBuilder.
 boolean isAdvancedQuery()
          Gets the value of the attribute: advancedQuery; Indicates if the statement uses advanced query capabilities.
 boolean isAdvancedQueryEnabled()
          Gets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.
 boolean isAggregateSelect()
          Gets the value of the attribute: aggregateSelect; Indicates if the statement has aggregate select .
 boolean isIncludeNestedParantheses()
          Gets the value of the attribute: includeNestedParantheses; Indicates if parantheses should be included for nested statements.
 boolean isQueryChunkSupported()
          Indicate if this compound queryspec can support chunking

Supported API: false
 boolean isSingleResultCompatible()
          Gets the value of the attribute: singleResultCompatible; Indicates if the query result should be returned as a single result (for backward compatibility)

Supported API: false
 boolean isUseBind()
          Gets the value of the attribute: useBind; Indicates if bind parameters should be used for this statement.
 boolean isUseComponentOrderBy()
          Gets the value of the attribute: useComponentOrderBy; Indicates if the order by clause should be taken from the first component of the compound statement.
 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(CompoundQuerySpec thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
private  void resultCursorValidate(ResultCursor a_ResultCursor)
           
 void setAdvancedQueryEnabled(boolean a_AdvancedQueryEnabled)
          Sets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.
 void setBindParameterAt(Object a_value, int a_index)
          

Supported API: false
 void setComponents(Vector a_Components)
          Sets the object for the association that plays role: components.
 void setFetchSize(int a_FetchSize)
          Sets the value of the attribute: fetchSize; A hint as to the number of rows that should be fetched from the database when more rows are needed.
 void setIncludeNestedParantheses(boolean a_IncludeNestedParantheses)
          Sets the value of the attribute: includeNestedParantheses; Indicates if parantheses should be included for nested statements.
 void setLocale(Locale a_locale)
          Set the client locale.
 void setResultCursor(ResultCursor a_ResultCursor)
          Sets the object for the association that plays role: resultCursor.
 void setSetOperator(SetOperator a_SetOperator)
          Sets the object for the association that plays role: setOperator.
 void setUseBind(boolean a_UseBind)
          Sets the value of the attribute: useBind; Indicates if bind parameters should be used for this statement.
 void setUseComponentOrderBy(boolean a_UseComponentOrderBy)
          Sets the value of the attribute: useComponentOrderBy; Indicates if the order by clause should be taken from the first component of the compound statement.
 String toString()
           
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

advancedQueryEnabled

private transient boolean advancedQueryEnabled

resultCursor

private ResultCursor resultCursor

statementBuilder

private CompoundStatementBuilder statementBuilder

resultBuilder

private ResultBuilder resultBuilder

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

thePrimary

private transient StatementSpec thePrimary
Constructor Detail

CompoundQuerySpec

public CompoundQuerySpec()
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
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
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(CompoundQuerySpec 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

isAdvancedQueryEnabled

public boolean isAdvancedQueryEnabled()
Gets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.

Supported API: true

Specified by:
isAdvancedQueryEnabled in interface StatementSpec
Returns:
boolean

setAdvancedQueryEnabled

public void setAdvancedQueryEnabled(boolean a_AdvancedQueryEnabled)
Sets the value of the attribute: advancedQueryEnabled; Indicates if advanced query capabilities are enabled.

Supported API: true

Specified by:
setAdvancedQueryEnabled in interface StatementSpec
Parameters:
a_AdvancedQueryEnabled -

isUseComponentOrderBy

public boolean isUseComponentOrderBy()
Gets the value of the attribute: useComponentOrderBy; Indicates if the order by clause should be taken from the first component of the compound statement. If false, then the explicit order by is used.

Supported API: false

Returns:
boolean

setUseComponentOrderBy

public void setUseComponentOrderBy(boolean a_UseComponentOrderBy)
Sets the value of the attribute: useComponentOrderBy; Indicates if the order by clause should be taken from the first component of the compound statement. If false, then the explicit order by is used.

Supported API: false

Parameters:
a_UseComponentOrderBy -

getComponents

public Vector getComponents()
Gets the object for the association that plays role: components.

Supported API: false

Returns:
Vector

setComponents

public void setComponents(Vector a_Components)
                   throws WTPropertyVetoException
Sets the object for the association that plays role: components.

Supported API: false

Parameters:
a_Components -
Throws:
WTPropertyVetoException

getResultCursor

public ResultCursor getResultCursor()
Gets the object for the association that plays role: resultCursor.

Supported API: false

Specified by:
getResultCursor in interface StatementSpec
Returns:
ResultCursor

setResultCursor

public void setResultCursor(ResultCursor a_ResultCursor)
                     throws WTPropertyVetoException
Sets the object for the association that plays role: resultCursor.

Supported API: false

Parameters:
a_ResultCursor -
Throws:
WTPropertyVetoException

resultCursorValidate

private void resultCursorValidate(ResultCursor a_ResultCursor)
                           throws WTPropertyVetoException
Parameters:
a_ResultCursor -
Throws:
WTPropertyVetoException

getSetOperator

public SetOperator getSetOperator()
Gets the object for the association that plays role: setOperator.

Supported API: true

Returns:
SetOperator

setSetOperator

public void setSetOperator(SetOperator a_SetOperator)
                    throws WTPropertyVetoException
Sets the object for the association that plays role: setOperator.

Supported API: true

Parameters:
a_SetOperator -
Throws:
WTPropertyVetoException

getStatementBuilder

public StatementBuilder getStatementBuilder()
Gets the object for the association that plays role: statementBuilder.

Supported API: false

Specified by:
getStatementBuilder in interface StatementSpec
Returns:
StatementBuilder

getResultBuilder

public ResultBuilder getResultBuilder()
Gets the object for the association that plays role: resultBuilder.

Supported API: false

Specified by:
getResultBuilder in interface StatementSpec
Returns:
ResultBuilder

addComponent

public void addComponent(StatementSpec a_statementSpec)
This method adds a component statement.

Supported API: true

Parameters:
a_statementSpec - Component statement to add

appendOrderBy

public void appendOrderBy(OrderBy a_orderBy)
                   throws QueryException
Appends an Order By expression to the compund query. The ColumnExpression contained in the OrderBy should have a column alias set.

Supported API: true

Parameters:
a_orderBy - OrderBy object to append
Throws:
QueryException

isQueryChunkSupported

public boolean isQueryChunkSupported()
Indicate if this compound queryspec can support chunking

Supported API: false

Returns:
boolean

getChunkableComponents

public ArrayList getChunkableComponents()
                                 throws WTException
Return a list of components which contains a larget value list greater than a configurable limit.

Supported API: false

Returns:
ArrayList
Throws:
WTException

getPrimaryClass

public Class getPrimaryClass()
Gets the value of the attribute: primaryClass; Primary class for the query.

Supported API: false

Specified by:
getPrimaryClass in interface StatementSpec
Returns:
Class

isSingleResultCompatible

public boolean isSingleResultCompatible()
Gets the value of the attribute: singleResultCompatible; Indicates if the query result should be returned as a single result (for backward compatibility)

Supported API: false

Specified by:
isSingleResultCompatible in interface StatementSpec
Returns:
boolean

getQueryLimit

public int getQueryLimit()
Gets the value of the attribute: queryLimit.

Supported API: false

Specified by:
getQueryLimit in interface StatementSpec
Returns:
int

isAdvancedQuery

public boolean isAdvancedQuery()
                        throws WTException
Gets the value of the attribute: advancedQuery; Indicates if the statement uses advanced query capabilities.

Supported API: false

Specified by:
isAdvancedQuery in interface StatementSpec
Returns:
boolean
Throws:
WTException

isAggregateSelect

public boolean isAggregateSelect()
Gets the value of the attribute: aggregateSelect; Indicates if the statement has aggregate select .

Supported API: false

Specified by:
isAggregateSelect in interface StatementSpec
Returns:
boolean

getCorrelatedClassAttributes

public List getCorrelatedClassAttributes()
Gets the value of the attribute: correlatedClassAttributes.

Supported API: false

Specified by:
getCorrelatedClassAttributes in interface StatementSpec
Returns:
List

isUseBind

public boolean isUseBind()
Gets the value of the attribute: useBind; Indicates if bind parameters should be used for this statement.

Supported API: true

Specified by:
isUseBind in interface StatementSpec
Returns:
boolean

setUseBind

public void setUseBind(boolean a_UseBind)
                throws WTPropertyVetoException
Sets the value of the attribute: useBind; Indicates if bind parameters should be used for this statement.

Supported API: true

Specified by:
setUseBind in interface StatementSpec
Parameters:
a_UseBind -
Throws:
WTPropertyVetoException

getFetchSize

public int getFetchSize()
Gets the value of the attribute: fetchSize; A hint as to the number of rows that should be fetched from the database when more rows are needed.

Supported API: false

Specified by:
getFetchSize in interface StatementSpec
Returns:
int

setFetchSize

public void setFetchSize(int a_FetchSize)
                  throws WTPropertyVetoException
Sets the value of the attribute: fetchSize; A hint as to the number of rows that should be fetched from the database when more rows are needed.

Supported API: false

Specified by:
setFetchSize in interface StatementSpec
Parameters:
a_FetchSize -
Throws:
WTPropertyVetoException

setLocale

public void setLocale(Locale a_locale)
               throws WTException
Set the client locale.

Supported API: true

Specified by:
setLocale in interface StatementSpec
Parameters:
a_locale -
Throws:
WTException

setBindParameterAt

public void setBindParameterAt(Object a_value,
                               int a_index)


Supported API: false

Specified by:
setBindParameterAt in interface StatementSpec
Parameters:
a_value -
a_index -

getBindParameterCount

public int getBindParameterCount()


Supported API: false

Specified by:
getBindParameterCount in interface StatementSpec
Returns:
int

isIncludeNestedParantheses

public boolean isIncludeNestedParantheses()
Gets the value of the attribute: includeNestedParantheses; Indicates if parantheses should be included for nested statements. This should always be included, but an Oracle bug can occur for top level statements. This attribute can be used as a workaround.

Supported API: true

Returns:
boolean

setIncludeNestedParantheses

public void setIncludeNestedParantheses(boolean a_IncludeNestedParantheses)
Sets the value of the attribute: includeNestedParantheses; Indicates if parantheses should be included for nested statements. This should always be included, but an Oracle bug can occur for top level statements. This attribute can be used as a workaround.

Supported API: true

Parameters:
a_IncludeNestedParantheses -

findNonEmptyComponent

private StatementSpec findNonEmptyComponent()
                                     throws WTException
Throws:
WTException

getPrimary

private StatementSpec getPrimary()

findMinimumLimit

private int findMinimumLimit(Vector components)

toString

public String toString()

getAllComponentQuerySpecs

public List getAllComponentQuerySpecs()

getAllComponentQuerySpecs

public List getAllComponentQuerySpecs(StatementSpec a_statementSpec,
                                      List a_querySpecs)