public abstract class MappingSqlQuery<T> extends MappingSqlQueryWithParameters<T>
Simplifies MappingSqlQueryWithParameters API by dropping parameters and context. Most subclasses won't care about parameters. If you don't use contextual information, subclass this instead of MappingSqlQueryWithParameters.
MappingSqlQueryWithParameters
MappingSqlQueryWithParameters.RowMapperImpl
logger
Constructor and Description |
---|
MappingSqlQuery()
Constructor that allows use as a JavaBean.
|
MappingSqlQuery(DataSource ds,
String sql)
Convenient constructor with DataSource and SQL string.
|
Modifier and Type | Method and Description |
---|---|
protected abstract T |
mapRow(ResultSet rs,
int rowNum)
Subclasses must implement this method to convert each row of the
ResultSet into an object of the result type.
|
protected T |
mapRow(ResultSet rs,
int rowNum,
Object[] parameters,
Map context)
This method is implemented to invoke the simpler mapRow
template method, ignoring parameters.
|
newRowMapper
execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, executeByNamedParam, executeByNamedParam, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObjectByNamedParam, findObjectByNamedParam, getRowsExpected, setRowsExpected
compileInternal, getParsedSql, newPreparedStatementCreator, newPreparedStatementCreator, newPreparedStatementSetter, onCompileInternal
afterPropertiesSet, allowsUnusedParameters, checkCompiled, compile, declareParameter, getDeclaredParameters, getGeneratedKeysColumnNames, getJdbcTemplate, getResultSetType, getSql, isCompiled, isReturnGeneratedKeys, isUpdatableResults, setDataSource, setFetchSize, setGeneratedKeysColumnNames, setJdbcTemplate, setMaxRows, setParameters, setQueryTimeout, setResultSetType, setReturnGeneratedKeys, setSql, setTypes, setUpdatableResults, supportsLobParameters, validateNamedParameters, validateParameters
public MappingSqlQuery()
public MappingSqlQuery(DataSource ds, String sql)
ds
- DataSource to use to obtain connectionssql
- SQL to runprotected final T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context) throws SQLException
mapRow
in class MappingSqlQueryWithParameters<T>
rs
- ResultSet we're working throughrowNum
- row number (from 0) we're up toparameters
- to the query (passed to the execute() method).
Subclasses are rarely interested in these.
It can be null
if there are no parameters.context
- passed to the execute() method.
It can be null
if no contextual information is need.SQLException
- if there's an error extracting data.
Subclasses can simply not catch SQLExceptions, relying on the
framework to clean up.mapRow(ResultSet, int)
protected abstract T mapRow(ResultSet rs, int rowNum) throws SQLException
Subclasses of this class, as opposed to direct subclasses of MappingSqlQueryWithParameters, don't need to concern themselves with the parameters to the execute method of the query object.
rs
- ResultSet we're working throughrowNum
- row number (from 0) we're up toSQLException
- if there's an error extracting data.
Subclasses can simply not catch SQLExceptions, relying on the
framework to clean up.