org.acmsl.queryj
Class SelectQuery

java.lang.Object
  |
  +--org.acmsl.queryj.Query
        |
        +--org.acmsl.queryj.SelectQuery
All Implemented Interfaces:
java.sql.PreparedStatement, java.sql.Statement

public abstract class SelectQuery
extends Query

Represents standard SQL select queries.

Version:
$Revision: 1.1 $
Author:
Jose San Leandro

Field Summary
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
SelectQuery()
          Constructs a query.
 
Method Summary
protected  void addField(Field field)
          Adds a new field.
protected  void addGroupingField(Field groupingField)
          Adds a new grouping field.
protected  void addOrderingField(Field orderingField)
          Adds a new ordering field.
 boolean execute(java.lang.String sql, Field[] fields)
          Executes given update operation using field references.
 java.sql.ResultSet executeQuery()
          See java.sql.PreparedStatement#executeQuery().
 int executeUpdate(java.lang.String sql, Field[] fields)
          Executes given update operation using field references.
 void from(Table table)
          Indicates which table participates in the query.
protected  int getFieldIndex(Field field)
          Retrieves the position of given field on the query.
protected  java.util.List getFields()
          Retrieves the field collection.
 java.sql.ResultSet getGeneratedKeys()
          See Statement#getGeneratedKeys()
protected  int getGroupingFieldIndex(Field field)
          Retrieves the position of given grouping field on the query.
protected  java.util.List getGroupingFields()
          Retrieves the grouping field collection.
protected  int getOrderingFieldIndex(Field field)
          Retrieves the position of given ordering field on the query.
protected  java.util.List getOrderingFields()
          Retrieves the ordering field collection.
 void groupBy(Field groupingField)
          Indicates a field to be used to group the results.
 void orderBy(Field orderingField)
          Indicates a field to be used to order the results.
 QueryResultSet retrieveMatchingResults()
          Looks for the records that match the filter.
 void select(Field field)
          Selects a field.
protected  void setFields(java.util.List list)
          Specifies new field collection.
protected  void setGroupingFields(java.util.List list)
          Specifies new grouping field collection.
protected  void setOrderingFields(java.util.List list)
          Specifies new ordering field collection.
 java.lang.String toString()
          Outputs a text version of the query, in SQL format.
 void where(Condition condition)
          Indicates a query condition.
 void where(VariableCondition variableCondition)
          Indicates a query variable condition.
 
Methods inherited from class org.acmsl.queryj.Query
addBatch, addBatch, addCondition, addTable, addVariableCondition, cancel, clearBatch, clearParameters, clearWarnings, close, execute, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConditions, getConnection, getFetchDirection, getFetchSize, getIndex, getMaxFieldSize, getMaxRows, getMetaData, getMoreResults, getMoreResults, getParameterMetaData, getPreparedStatement, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getTables, getUpdateCount, getVariableConditions, getWarnings, prepareStatement, setArray, setArray, setAsciiStream, setAsciiStream, setBigDecimal, setBigDecimal, setBinaryStream, setBinaryStream, setBlob, setBlob, setBoolean, setBoolean, setByte, setByte, setBytes, setBytes, setCharacterStream, setCharacterStream, setClob, setClob, setConditions, setCursorName, setDate, setDate, setDate, setDate, setDouble, setDouble, setEscapeProcessing, setFetchDirection, setFetchSize, setFloat, setFloat, setInt, setInt, setLong, setLong, setMaxFieldSize, setMaxRows, setNull, setNull, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setObject, setPreparedStatement, setQueryTimeout, setRef, setRef, setShort, setShort, setString, setString, setTables, setTime, setTime, setTime, setTime, setTimestamp, setTimestamp, setTimestamp, setTimestamp, setUnicodeStream, setUnicodeStream, setURL, setVariableConditions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectQuery

public SelectQuery()
Constructs a query.

Method Detail

setFields

protected void setFields(java.util.List list)
Specifies new field collection.

Parameters:
list - the new list.

getFields

protected java.util.List getFields()
Retrieves the field collection.

Returns:
such list.

addField

protected void addField(Field field)
Adds a new field.

Parameters:
field - the field to add.

getFieldIndex

protected int getFieldIndex(Field field)
Retrieves the position of given field on the query.

Parameters:
field - the field to find.
Returns:
its position, or -1 if such field doesn't belong to this query.

setOrderingFields

protected void setOrderingFields(java.util.List list)
Specifies new ordering field collection.

Parameters:
list - the new list.

getOrderingFields

protected java.util.List getOrderingFields()
Retrieves the ordering field collection.

Returns:
such list.

addOrderingField

protected void addOrderingField(Field orderingField)
Adds a new ordering field.

Parameters:
orderingField - the ordering field to add.

getOrderingFieldIndex

protected int getOrderingFieldIndex(Field field)
Retrieves the position of given ordering field on the query.

Parameters:
field - the field to find.
Returns:
its position, or -1 if such field doesn't belong to this query.

setGroupingFields

protected void setGroupingFields(java.util.List list)
Specifies new grouping field collection.

Parameters:
list - the new list.

getGroupingFields

protected java.util.List getGroupingFields()
Retrieves the grouping field collection.

Returns:
such list.

addGroupingField

protected void addGroupingField(Field groupingField)
Adds a new grouping field.

Parameters:
groupingField - the grouping field to add.

getGroupingFieldIndex

protected int getGroupingFieldIndex(Field field)
Retrieves the position of given grouping field on the query.

Parameters:
field - the field to find.
Returns:
its position, or -1 if such field doesn't belong to this query.

select

public void select(Field field)
Selects a field.

Parameters:
field - the field to select.

from

public void from(Table table)
Indicates which table participates in the query.

Parameters:
table - the table.

where

public void where(Condition condition)
Indicates a query condition.

Parameters:
condition - such condition.

where

public void where(VariableCondition variableCondition)
Indicates a query variable condition.

Parameters:
variableCondition - such variable condition.

groupBy

public void groupBy(Field groupingField)
Indicates a field to be used to group the results.

Parameters:
groupingField - such field.

orderBy

public void orderBy(Field orderingField)
Indicates a field to be used to order the results.

Parameters:
orderingField - such field.

retrieveMatchingResults

public QueryResultSet retrieveMatchingResults()
                                       throws java.sql.SQLException
Looks for the records that match the filter.

Specified by:
retrieveMatchingResults in class Query
Returns:
(Taken from Sun's Javadoc) a ResultSet object that contains the data produced by the given query; never null.
Throws:
java.sql.SQLException - if an error occurs.

executeQuery

public java.sql.ResultSet executeQuery()
                                throws java.sql.SQLException
See java.sql.PreparedStatement#executeQuery().

Specified by:
executeQuery in interface java.sql.PreparedStatement
Specified by:
executeQuery in class Query
Returns:
(Taken from Sun's Javadoc) a ResultSet object that contains the data produced by the query; never null.
Throws:
java.sql.SQLException - if an error occurs.
See Also:
PreparedStatement.executeQuery()

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
See Statement#getGeneratedKeys()

Specified by:
getGeneratedKeys in interface java.sql.Statement
Specified by:
getGeneratedKeys in class Query
Returns:
(Taken from Sun's Javadoc) a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object.
Throws:
java.sql.SQLException - if an error occurs.
See Also:
Statement.getGeneratedKeys()

executeUpdate

public int executeUpdate(java.lang.String sql,
                         Field[] fields)
                  throws java.sql.SQLException
Executes given update operation using field references.

Parameters:
sql - (Taken from Sun's Javadoc) must be an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing.
fields - the fields.
Returns:
(Taken from Sun's Javadoc) either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing.
Throws:
java.sql.SQLException - if an error occurs.

execute

public boolean execute(java.lang.String sql,
                       Field[] fields)
                throws java.sql.SQLException
Executes given update operation using field references.

Parameters:
sql - (Taken from Sun's Javadoc) must be an SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing.
fields - the fields.
Returns:
(Taken from Sun's Javadoc) true if the first result is a ResultSet object; false if it is an update count or there are no results.
Throws:
java.sql.SQLException - if an error occurs.

toString

public java.lang.String toString()
Outputs a text version of the query, in SQL format.

Overrides:
toString in class java.lang.Object
Returns:
the SQL query.


Copyright © 2003 ACM S.L.. All Rights Reserved.