wt.pds
Class ObjectReferenceStatementBuilder

java.lang.Object
  extended bywt.pds.BasicStatementBuilder
      extended bywt.pds.ObjectReferenceStatementBuilder
All Implemented Interfaces:
Externalizable, Serializable, StatementBuilder

public class ObjectReferenceStatementBuilder
extends BasicStatementBuilder
implements Externalizable

This class builds select statements for Object References of a given class. The ObjectReferences are set via an attribute OidArray. To build the SQL statements, the array is processed to determine the concrete tables that need to be queried. The ObjectReferences can reference the targetClass or any of its descendant classes. For each concrete table, a SQL statement is built returning all of the attributes necessary to build a full object. The SQL statements will use the associated whereClause and table expressions for the appropriate object IDs. Table expressions are used so that associated object IDs and duplicate object IDs from the OidArray are returned correctly.

Supported API: false

Extendable: false

See Also:
Serialized Form

Nested Class Summary
(package private) static class ObjectReferenceStatementBuilder.IdList
           
(package private) static class ObjectReferenceStatementBuilder.SingleColumnUniqueIdList
           
 
Field Summary
private  Object[] bindParameters
           
private static String CLASSNAME
           
private static String DELIMITER
           
static long EXTERNALIZATION_VERSION_UID
           
private  FromClause fromClause
           
private static Vector HINTS
           
private static Class[] ID_LIST_TYPE
           
private static String OID_ALIAS
           
private  OidArray oidArray
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
private  boolean singleTableMode
           
private static boolean TYPE_USAGE_ENABLED
           
private  WhereClause whereClause
           
 
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
ObjectReferenceStatementBuilder()
          

Supported API: false
 
Method Summary
private static TableExpression buildConstantTableExpression(ObjectReferenceStatementBuilder.IdList a_idList, int a_columnCount, int a_beginIndex, int a_endIndex)
           
private  Vector buildOidTableExpressions(ObjectReferenceStatementBuilder.IdList a_idList)
           
 String[] buildSQL(ResultBuilder a_resultBuilder, WTConnection a_connection, boolean a_isComponent, boolean a_isComponentChunkSupported)
          Returns an array of JDBC statements to execute.
private  String getClassNameKey(int a_rowIndex)
           
 FromClause getFromClause()
          Gets the object for the association that plays role: fromClause.
 OidArray getOidArray()
          Gets the object for the association that plays role: oidArray.
 boolean getSingleTableMode()
           
 Vector getStatementBindParameters(int a_sqlIndex)
          Returns a Vector of bind parameters for the specified statement.
private  ClassTableExpression getTableExpression(String a_className, int a_fromIndex)
           
private  void getTables(String a_classNames, Vector a_tables)
           
 WhereClause getWhereClause()
          Gets the object for the association that plays role: whereClause.
private  boolean isAllUniqueIds(HashMap a_classIds)
           
private  void oidArrayValidate(OidArray a_OidArray)
           
 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(ObjectReferenceStatementBuilder thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 void setOidArray(OidArray a_OidArray)
          Sets the object for the association that plays role: oidArray.
 void setSingleTableMode(boolean a_singleTableMode)
           
 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, 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

whereClause

private WhereClause whereClause

fromClause

private FromClause fromClause

oidArray

private OidArray oidArray

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

bindParameters

private transient Object[] bindParameters

singleTableMode

private transient boolean singleTableMode

DELIMITER

private static final String DELIMITER
See Also:
Constant Field Values

ID_LIST_TYPE

private static final Class[] ID_LIST_TYPE

OID_ALIAS

private static final String OID_ALIAS
See Also:
Constant Field Values

TYPE_USAGE_ENABLED

private static final boolean TYPE_USAGE_ENABLED
See Also:
Constant Field Values

HINTS

private static final Vector HINTS
Constructor Detail

ObjectReferenceStatementBuilder

public ObjectReferenceStatementBuilder()


Supported API: false

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(ObjectReferenceStatementBuilder 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

getWhereClause

public WhereClause getWhereClause()
Gets the object for the association that plays role: whereClause.

Supported API: false

Returns:
WhereClause

getFromClause

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

Supported API: false

Returns:
FromClause

getOidArray

public OidArray getOidArray()
Gets the object for the association that plays role: oidArray.

Supported API: false

Returns:
OidArray

setOidArray

public void setOidArray(OidArray a_OidArray)
                 throws WTPropertyVetoException
Sets the object for the association that plays role: oidArray.

Supported API: false

Parameters:
a_OidArray -
Throws:
WTPropertyVetoException

oidArrayValidate

private void oidArrayValidate(OidArray a_OidArray)
                       throws WTPropertyVetoException
Parameters:
a_OidArray -
Throws:
WTPropertyVetoException

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

getStatementBindParameters

public Vector getStatementBindParameters(int a_sqlIndex)
                                  throws PersistenceException
Returns a Vector of bind parameters for the specified statement.

Supported API: false

Specified by:
getStatementBindParameters in interface StatementBuilder
Specified by:
getStatementBindParameters in class BasicStatementBuilder
Parameters:
a_sqlIndex -
Returns:
Vector
Throws:
PersistenceException

getSingleTableMode

public boolean getSingleTableMode()

setSingleTableMode

public void setSingleTableMode(boolean a_singleTableMode)

isAllUniqueIds

private boolean isAllUniqueIds(HashMap a_classIds)

getClassNameKey

private String getClassNameKey(int a_rowIndex)

getTables

private void getTables(String a_classNames,
                       Vector a_tables)
                throws WTException,
                       ClassNotFoundException
Throws:
WTException
ClassNotFoundException

getTableExpression

private ClassTableExpression getTableExpression(String a_className,
                                                int a_fromIndex)
                                         throws WTException,
                                                ClassNotFoundException
Throws:
WTException
ClassNotFoundException

buildOidTableExpressions

private Vector buildOidTableExpressions(ObjectReferenceStatementBuilder.IdList a_idList)
                                 throws WTException
Throws:
WTException

buildConstantTableExpression

private static TableExpression buildConstantTableExpression(ObjectReferenceStatementBuilder.IdList a_idList,
                                                            int a_columnCount,
                                                            int a_beginIndex,
                                                            int a_endIndex)