org.apache.ojb.broker.accesslayer.sql
Class SqlSelectStatement

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement
      extended by org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement
All Implemented Interfaces:
JoinSyntaxTypes, SelectStatement, SqlStatement
Direct Known Subclasses:
SqlSelectByPkStatement

public class SqlSelectStatement
extends SqlQueryStatement
implements SelectStatement

Model a SELECT Statement

Version:
$Id: SqlSelectStatement.java,v 1.1 2007-08-24 22:17:39 ewestfal Exp $
Author:
Jakob Braeuchi

Field Summary
 
Fields inherited from class org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement
m_attrToFld
 
Fields inherited from interface org.apache.ojb.broker.accesslayer.JoinSyntaxTypes
ORACLE_JOIN_SYNTAX, SQL92_JOIN_SYNTAX, SQL92_NOPAREN_JOIN_SYNTAX, SYBASE_JOIN_SYNTAX
 
Constructor Summary
SqlSelectStatement(Platform pf, ClassDescriptor cld, Query query, Logger logger)
          Constructor for SqlSelectStatement.
SqlSelectStatement(SqlQueryStatement parent, Platform pf, ClassDescriptor cld, Query query, Logger logger)
          Constructor for SqlSelectStatement.
 
Method Summary
protected  void appendColumn(org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.TableAlias anAlias, FieldDescriptor field, StringBuffer buf)
          Append a Column with alias: A0 name -> A0.name
protected  void appendField(FieldDescriptor fld, StringBuffer buf)
          Append column name.
protected  List appendListOfColumns(String[] columns, StringBuffer buf)
          Appends to the statement a comma separated list of column names.
protected  List appendListOfColumnsForSelect(StringBuffer buf)
          Appends to the statement a comma separated list of column names.
protected  void appendTable(ClassDescriptor cld, StringBuffer buf)
          Append table name.
protected  FieldDescriptor[] buildFieldsForSelect(ClassDescriptor cld)
          Return the Fields to be selected.
protected  String buildStatement()
          Build the SQL String.
 int getColumnIndex(FieldDescriptor fld)
          Returns the column index of the specified FieldDescriptor in the ResultSet after performing the query.
protected  FieldDescriptor[] getFieldsForSelect()
          Return the Fields to be selected.
 Query getQueryInstance()
          Returns the Query instance this statement based on.
 
Methods inherited from class org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement
appendClause, appendColName, appendColName, appendColName, appendCriteria, appendGroupByClause, appendHavingClause, appendOrderByClause, appendSQLClause, appendTableWithJoins, appendWhereClause, buildSuperJoinTree, ensureColumns, ensureColumns, getAttributeInfo, getBaseClassDescriptor, getColName, getFieldDescriptor, getJoinSyntaxType, getJoinTreeToCriteria, getLogger, getQuery, getRoot, getSearchClassDescriptor, getSearchTable, getStatement, getTableAliasForClassDescriptor, setRoot, splitCriteria
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.ojb.broker.accesslayer.sql.SqlStatement
getStatement
 

Constructor Detail

SqlSelectStatement

public SqlSelectStatement(Platform pf,
                          ClassDescriptor cld,
                          Query query,
                          Logger logger)
Constructor for SqlSelectStatement.

Parameters:
pf -
cld -
query -
logger -

SqlSelectStatement

public SqlSelectStatement(SqlQueryStatement parent,
                          Platform pf,
                          ClassDescriptor cld,
                          Query query,
                          Logger logger)
Constructor for SqlSelectStatement.

Parameters:
parent -
pf -
cld -
query -
logger -
Method Detail

appendColumn

protected void appendColumn(org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.TableAlias anAlias,
                            FieldDescriptor field,
                            StringBuffer buf)
Append a Column with alias: A0 name -> A0.name

Parameters:
anAlias - the TableAlias
field -
buf -

appendListOfColumnsForSelect

protected List appendListOfColumnsForSelect(StringBuffer buf)
Appends to the statement a comma separated list of column names. DO NOT use this if order of columns is important. The row readers build reflectively and look up column names to find values, so this is safe. In the case of update, you CANNOT use this as the order of columns is important.

Returns:
list of column names for the set of all unique columns for multiple classes mapped to the same table.

getFieldsForSelect

protected FieldDescriptor[] getFieldsForSelect()
Return the Fields to be selected.

Returns:
the Fields to be selected

buildFieldsForSelect

protected FieldDescriptor[] buildFieldsForSelect(ClassDescriptor cld)
Return the Fields to be selected.

Parameters:
cld - the ClassDescriptor
Returns:
the Fields to be selected

appendListOfColumns

protected List appendListOfColumns(String[] columns,
                                   StringBuffer buf)
Appends to the statement a comma separated list of column names.

Parameters:
columns - defines the columns to be selected (for reports)
Returns:
list of column names

buildStatement

protected String buildStatement()
Description copied from class: SqlQueryStatement
Build the SQL String.

Specified by:
buildStatement in class SqlQueryStatement
Returns:
SQL String
See Also:
SqlQueryStatement.buildStatement()

appendTable

protected void appendTable(ClassDescriptor cld,
                           StringBuffer buf)
Append table name. Quote if necessary.


appendField

protected void appendField(FieldDescriptor fld,
                           StringBuffer buf)
Append column name. Quote if necessary.


getQueryInstance

public Query getQueryInstance()
Description copied from interface: SelectStatement
Returns the Query instance this statement based on.

Specified by:
getQueryInstance in interface SelectStatement
Returns:
The Query instance or null if no query is used to generate the select string.

getColumnIndex

public int getColumnIndex(FieldDescriptor fld)
Description copied from interface: SelectStatement
Returns the column index of the specified FieldDescriptor in the ResultSet after performing the query.

Specified by:
getColumnIndex in interface SelectStatement
Parameters:
fld - The FieldDescriptor.
Returns:
The column index or JdbcType.MIN_INT if column index is not supported.


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.