org.sormula.operation
Class SelectOperation<R,C>

java.lang.Object
  extended by org.sormula.operation.SqlOperation<R>
      extended by org.sormula.operation.ScalarSelectOperation<R>
          extended by org.sormula.operation.SelectOperation<R,C>
Type Parameters:
R - class type which contains members for columns of a row in a table
C - collection type returned
Direct Known Subclasses:
ListSelectOperation, MapSelectOperation

public abstract class SelectOperation<R,C>
extends ScalarSelectOperation<R>

SQL select operation returning a collection of rows.

Since:
1.0
Author:
Jeff Miller

Constructor Summary
SelectOperation(Table<R> table)
          Constructs standard sql to select by primary key as: SELECT c1, c2, c3, ...
SelectOperation(Table<R> table, java.lang.String whereConditionName)
          Constructs standard sql to by a where condition: SELECT c1, c2, c3, ...
 
Method Summary
protected abstract  boolean add(R row)
          Implement to add row to collection created createReadAllCollection().
protected abstract  C createReadAllCollection()
          Implement to create collection to use by readAll().
 int getDefaultReadAllSize()
          Gets the default size to allocate for Collection C by createReadAllCollection().
 C getSelectedRows()
          Gets collection of rows that were selected with readAll().
 C readAll()
          Reads all rows from current result set.
 C selectAll(java.lang.Object... parameters)
          Set parameters, executes, reads all rows in result set, closes.
 C selectAll(R whereParameters)
          Set parameters, executes, reads all rows in result set, closes.
 void setDefaultReadAllSize(int defaultReadAllSize)
          Sets default initial capacity for collection that is to contain the selected rows.
 
Methods inherited from class org.sormula.operation.ScalarSelectOperation
close, execute, getMaximumRowsRead, getOrderByName, getOrderByTranslator, getResultSet, getRowsReadCount, getSql, initBaseSql, isLazySelectsCascades, isNotifyLazySelects, postRead, postReadCascade, prepareCascades, preRead, preReadCascade, readNext, select, select, setMaximumRowsRead, setOrderBy, setOrderByTranslator, setParameters, setRowParameters
 
Methods inherited from class org.sormula.operation.SqlOperation
cancel, cascade, closeCascades, closeStatement, createTargetField, getBaseSql, getConnection, getCustomSql, getNextParameter, getOperationTime, getParameters, getPreparedSql, getPreparedStatement, getQueryTimeout, getTable, getTargetTable, getTimingId, getWhereConditionName, getWhereTranslator, initOperationTime, isAutoGeneratedKeys, isIncludeIdentityColumns, isReadOnly, isTimings, logTimings, prepare, prepareCascades, prepareCheck, prepareColumns, prepareParameters, prepareWhere, setAutoGeneratedKeys, setBaseSql, setCustomSql, setIncludeIdentityColumns, setNextParameter, setQueryTimeout, setReadOnly, setTimingId, setTimings, setWhere, setWhereTranslator, writeColumns, writeParameter, writeParameters, writeWhere
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectOperation

public SelectOperation(Table<R> table)
                throws OperationException
Constructs standard sql to select by primary key as: SELECT c1, c2, c3, ... FROM table WHERE primary key clause

Parameters:
table - select from this table
Throws:
OperationException - if error

SelectOperation

public SelectOperation(Table<R> table,
                       java.lang.String whereConditionName)
                throws OperationException
Constructs standard sql to by a where condition: SELECT c1, c2, c3, ... FROM table WHERE...

Parameters:
table - select from this table
whereConditionName - name of where condition to use ("primaryKey" to select by primary key; empty string to select all rows in table)
Throws:
OperationException - if error
Method Detail

getDefaultReadAllSize

public int getDefaultReadAllSize()
Gets the default size to allocate for Collection C by createReadAllCollection().

Returns:
default size to allocate for collection that contains row objects

setDefaultReadAllSize

public void setDefaultReadAllSize(int defaultReadAllSize)
Sets default initial capacity for collection that is to contain the selected rows. For large result sets, setting the default capacity may reduce time to build the collection.

Parameters:
defaultReadAllSize - initial collection capacity; default is 20

readAll

public C readAll()
          throws OperationException
Reads all rows from current result set. For large result sets, invoking setDefaultReadAllSize(int) may improve performance.

Returns:
collection of rows from query
Throws:
OperationException - if error

getSelectedRows

public C getSelectedRows()
Gets collection of rows that were selected with readAll().

Returns:
collection of rows; null if readAll() has not been invoked

selectAll

public C selectAll(java.lang.Object... parameters)
            throws OperationException
Set parameters, executes, reads all rows in result set, closes.

Parameters:
parameters - query parameters as objects (see ScalarSelectOperation.setParameters(Object...))
Returns:
readAll()
Throws:
OperationException - if error
Since:
1.4

selectAll

public C selectAll(R whereParameters)
            throws OperationException
Set parameters, executes, reads all rows in result set, closes.

Parameters:
whereParameters - query parameters are read from an existing row object (see ScalarSelectOperation.setParameters(Object...))
Returns:
readAll()
Throws:
OperationException - if error
Since:
1.4

createReadAllCollection

protected abstract C createReadAllCollection()
Implement to create collection to use by readAll().

Returns:
collection to use for readAll()

add

protected abstract boolean add(R row)
                        throws OperationException
Implement to add row to collection created createReadAllCollection().

Parameters:
row - row to add
Returns:
true if added ok
Throws:
OperationException - if error