com.is.jrf
Class SelectSQLBuilder

java.lang.Object
  |
  +--com.is.jrf.SQLBuilder
        |
        +--com.is.jrf.SelectSQLBuilder

public class SelectSQLBuilder
extends SQLBuilder

Instances of this class build SQL to do SELECT statements. This has it's own instance so that variables can be changed without affecting the domain object. For purposes of selecting, subtype tables are treated like join tables.


Field Summary
protected  java.util.List i_joinTables
          Copy of the JoinTable object list
protected  java.lang.String i_orderBy
           
protected  boolean i_useANSIJoins
           
protected  java.lang.String i_where
           
 
Fields inherited from class com.is.jrf.SQLBuilder
i_columnSpecs, i_dbPolicy, i_domain, i_tableAlias, i_tableName
 
Constructor Summary
SelectSQLBuilder()
          This constructor throws an exception.
SelectSQLBuilder(AbstractDomain domain)
           
 
Method Summary
 void addJoinTable(JoinTable aJoinTable)
           
 void addJoinTable(java.lang.String tableName)
          Create and add a new JoinTable instance with no join columns.
 void addOuterJoinTable(java.lang.String tableName)
          Create and add a new OuterJoinTable instance with no join columns.
 java.lang.String buildCountSQL(java.lang.String tableName, ColumnSpec primaryKeyColumnSpec, PersistentObject aPO, DatabasePolicy dbPolicy)
          Build SQL that will count the rows for the given primary key column spec.
 java.lang.String buildSQL()
          Build the SQL using the information I have.
 void setOrderBy(java.lang.String orderByString)
          This should be an orderBy string without the 'ORDER BY'.
 void setUseANSIJoins(boolean b)
          Set to true when ANSI joins are required.
 void setWhere(java.lang.String whereString)
          This should be a where string without the WHERE.
 
Methods inherited from class com.is.jrf.SQLBuilder
getColumnSpecs, getDatabasePolicy, getTableAlias, getTableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i_joinTables

protected java.util.List i_joinTables
Copy of the JoinTable object list

i_where

protected java.lang.String i_where

i_orderBy

protected java.lang.String i_orderBy

i_useANSIJoins

protected boolean i_useANSIJoins
Constructor Detail

SelectSQLBuilder

public SelectSQLBuilder()
This constructor throws an exception.

SelectSQLBuilder

public SelectSQLBuilder(AbstractDomain domain)
Method Detail

addJoinTable

public void addJoinTable(JoinTable aJoinTable)

addJoinTable

public void addJoinTable(java.lang.String tableName)
Create and add a new JoinTable instance with no join columns. It is assumed the user will manually set the joins using the setWhereString() method. This string can be of the form: 'Video' or 'Video V' (where V is the table alias)
Parameters:
tableName - a value of type 'String'

addOuterJoinTable

public void addOuterJoinTable(java.lang.String tableName)
Create and add a new OuterJoinTable instance with no join columns. It is assumed the user will manually set the joins using the setWhereString() method. This string can be of the form: 'Video' or 'Video V' (with table alias)
Parameters:
tableName - a value of type 'String'

setWhere

public void setWhere(java.lang.String whereString)
This should be a where string without the WHERE.
Parameters:
whereString - a value of type 'String'

setOrderBy

public void setOrderBy(java.lang.String orderByString)
This should be an orderBy string without the 'ORDER BY'.
Parameters:
orderByString - a value of type 'String'

setUseANSIJoins

public void setUseANSIJoins(boolean b)
Set to true when ANSI joins are required. ANSI joins look like this:

SELECT col1 FROM table1
JOIN table2 ON table1.col1=table2.col1
WHERE table1.col3='something'
Parameters:
b - a value of type 'boolean'

buildSQL

public java.lang.String buildSQL()
Build the SQL using the information I have. The SQL generated by this includes the joined columns.
Returns:
a value of type 'String'

buildCountSQL

public java.lang.String buildCountSQL(java.lang.String tableName,
                                      ColumnSpec primaryKeyColumnSpec,
                                      PersistentObject aPO,
                                      DatabasePolicy dbPolicy)
Build SQL that will count the rows for the given primary key column spec. It is assumed that execution of this SQL will result in a 0 or a 1.