R
- class type which contains members for columns of a row in a tableC
- collection type returnedpublic abstract class SelectOperation<R,C> extends ScalarSelectOperation<R>
Constructor and Description |
---|
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, ...
|
Modifier and Type | Method and Description |
---|---|
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() . |
int |
getFetchSize()
Gets the JDBC fetch size set with
setFetchSize(int) . |
int |
getResultSetType()
Gets the type of result set to use.
|
C |
getSelectedRows()
Gets collection of rows that were selected with
readAll() . |
protected java.sql.PreparedStatement |
prepareStatement()
Creates the prepared statement.
|
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.
|
void |
setFetchSize(int fetchSize)
Sets the JDBC fetch size to use for prepared statement.
|
void |
setResultSetType(int resultSetType)
Sets the type of result set to use.
|
void |
setWhere(java.lang.String whereConditionName)
Sets where condition from annotation name as defined in
Where.name() for row. |
addFilter, close, execute, getFilterPredicateMap, getMaximumRowsRead, getOrderByName, getOrderByTranslator, getResultSet, getRowsReadCount, getSql, initBaseSql, isExecuted, isLazySelectsCascades, isNotifyLazySelects, iterator, positionAbsolute, positionRelative, postRead, postReadCascade, prepareCascades, preRead, preReadCascade, readNext, removeFilter, resetRowsReadCount, select, select, setFilterPredicateMap, setMaximumRowsRead, setOrderBy, setOrderByTranslator, setParameters, setRowParameters, updateActiveFilterPredicate
cancel, cascade, closeCascades, closeStatement, createRowField, getBaseSql, getCascadeDepth, getConnection, getCustomSql, getNamedParameterMap, getNextParameter, getOperationTime, getParameter, getParameters, getPreparedSql, getPreparedStatement, getQueryTimeout, getRequiredCascades, getTable, getTargetTable, getTimingId, getWhereAnnotation, getWhereConditionName, getWhereTranslator, initOperationTime, isCached, isCascade, isCascading, isIncludeIdentityColumns, isPrimaryKey, isReadOnly, isRequiredCascade, isTimings, logTimings, prepare, prepareCascades, prepareCheck, setBaseSql, setCached, setCascade, setCascadeDepth, setCustomSql, setIncludeIdentityColumns, setNamedParameterMap, setNextParameter, setParameter, setQueryTimeout, setReadOnly, setRequiredCascades, setTimingId, setTimings, setWhereTranslator, writeColumns, writeParameter, writeParameters, writeWhere
public SelectOperation(Table<R> table) throws OperationException
table
- select from this tableOperationException
- if errorpublic SelectOperation(Table<R> table, java.lang.String whereConditionName) throws OperationException
table
- select from this tablewhereConditionName
- name of where condition to use ("primaryKey" to select
by primary key; empty string to select all rows in table)OperationException
- if errorpublic int getDefaultReadAllSize()
Collection
C by createReadAllCollection()
.public void setDefaultReadAllSize(int defaultReadAllSize)
defaultReadAllSize
- initial collection capacity; default is 20public void setWhere(java.lang.String whereConditionName) throws OperationException
Where.name()
for row.
Invokes superclass method and then sets the initial capacity setDefaultReadAllSize(int)
if there is a where annotation.setWhere
in class SqlOperation<R>
whereConditionName
- name of where condition to use;
"primaryKey" for key defined by Column.primaryKey()
, Column.identity()
,
or Row.primaryKeyFields()
; empty string for no where conditionOperationException
- if errorpublic C readAll() throws OperationException
setDefaultReadAllSize(int)
may improve performance.OperationException
- if errorpublic C getSelectedRows()
readAll()
.readAll()
has not been invokedpublic C selectAll(java.lang.Object... parameters) throws OperationException
Since this class implements AutoCloseable
, you may see resource leak
warning when you use this method. You can ignore it, add a suppress annotation,
explicitly close, or close with a try-with-resources statement. Closing an operation
more than once will not cause problems since the close methods are idempotent.
parameters
- query parameters as objects (see ScalarSelectOperation.setParameters(Object...)
)readAll()
OperationException
- if errorpublic C selectAll(R whereParameters) throws OperationException
Since this class implements AutoCloseable
, you may see resource leak
warning when you use this method. You can ignore it, add a suppress annotation,
explicitly close, or close with a try-with-resources statement. Closing an operation
more than once will not cause problems since the close methods are idempotent.
whereParameters
- query parameters are read from an existing row object
(see ScalarSelectOperation.setParameters(Object...)
)readAll()
OperationException
- if errorpublic int getFetchSize()
setFetchSize(int)
. The default is zero.Statement.setFetchSize(int)
public void setFetchSize(int fetchSize)
SqlOperation.prepare()
with
Statement.setFetchSize(int)
.fetchSize
- prepared statement fetch sizeStatement.setFetchSize(int)
public int getResultSetType()
ResultSet.TYPE_FORWARD_ONLY
, ResultSet.TYPE_SCROLL_INSENSITIVE
, or
ResultSet.TYPE_SCROLL_SENSITIVE
public void setResultSetType(int resultSetType)
ResultSet.TYPE_FORWARD_ONLY
. Use this
method prior to ScalarSelectOperation.execute()
. Setting result set type after ScalarSelectOperation.execute()
has no affect.resultSetType
- ResultSet.TYPE_FORWARD_ONLY
, ResultSet.TYPE_SCROLL_INSENSITIVE
, or
ResultSet.TYPE_SCROLL_SENSITIVE
protected java.sql.PreparedStatement prepareStatement() throws java.sql.SQLException
setResultSetType(int)
and
concurrency of ResultSet.CONCUR_READ_ONLY
.prepareStatement
in class SqlOperation<R>
java.sql.SQLException
- if errorprotected abstract C createReadAllCollection()
readAll()
.readAll()
protected abstract boolean add(R row) throws OperationException
createReadAllCollection()
.row
- row to addOperationException
- if error