org.sormula.operation
Class SelectCountOperation<R>

java.lang.Object
  extended by org.sormula.operation.SqlOperation<R>
      extended by org.sormula.operation.ScalarSelectOperation<R>
          extended by org.sormula.operation.SelectCountOperation<R>
Type Parameters:
R - class type which contains members for columns of a row in a table

public class SelectCountOperation<R>
extends ScalarSelectOperation<R>

SQL select count of records operation. By default selects count of all rows in table. Set where condition with SqlOperation.setWhere(String) to count subset of all rows.

This class remains in this package for backward compatibility. org.sormula.operation.aggregate contains a replacement for this class and it contains other aggregate operations.

Since:
1.0
Author:
Jeff Miller
See Also:
SelectCountOperation

Constructor Summary
SelectCountOperation(Table<R> table)
          Constructs standard sql select by primary key as:
SELECT COUNT(*), ...
SelectCountOperation(Table<R> table, java.lang.String whereConditionName)
          Constructs standard sql select as:
SELECT COUNT(*), ...
 
Method Summary
protected  void initBaseSql()
          Sets base sql with SqlOperation.setBaseSql(String).
 java.lang.Integer readCount()
          Reads the count of rows.
 R readNext()
          Use readCount() instead.
 
Methods inherited from class org.sormula.operation.ScalarSelectOperation
close, execute, getMaximumRowsRead, getOrderByName, getOrderByTranslator, getResultSet, getRowsReadCount, getSql, isLazySelectsCascades, isNotifyLazySelects, postRead, postReadCascade, prepareCascades, preRead, preReadCascade, 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

SelectCountOperation

public SelectCountOperation(Table<R> table)
                     throws OperationException
Constructs standard sql select by primary key as:
SELECT COUNT(*), ... FROM table WHERE primary key clause

Parameters:
table - insert into this table
Throws:
OperationException - if error

SelectCountOperation

public SelectCountOperation(Table<R> table,
                            java.lang.String whereConditionName)
                     throws OperationException
Constructs standard sql select as:
SELECT COUNT(*), ... FROM table WHERE ...

Parameters:
table - insert into 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

initBaseSql

protected void initBaseSql()
Sets base sql with SqlOperation.setBaseSql(String).

Overrides:
initBaseSql in class ScalarSelectOperation<R>

readNext

public R readNext()
           throws OperationException
Use readCount() instead. R class rows are not returned from select count(*).

Overrides:
readNext in class ScalarSelectOperation<R>
Returns:
new instance of row or null if no more row in the current result set
Throws:
OperationException - for all invocations

readCount

public java.lang.Integer readCount()
                            throws OperationException
Reads the count of rows. Invoke ScalarSelectOperation.execute() prior to using this method.

Returns:
value of count or -1 if count can't be read
Throws:
OperationException - if error