| java.lang.Object org.springframework.jdbc.object.RdbmsOperation org.springframework.jdbc.object.SqlOperation org.springframework.jdbc.object.SqlQuery org.springframework.jdbc.object.MappingSqlQueryWithParameters
All known Subclasses: org.springframework.jdbc.object.MappingSqlQuery,
MappingSqlQueryWithParameters | abstract public class MappingSqlQueryWithParameters extends SqlQuery (Code) | | Reusable RDBMS query in which concrete subclasses must implement
the abstract mapRow(ResultSet, int) method to map each row of
the JDBC ResultSet into an object.
Such manual mapping is usually preferable to "automatic"
mapping using reflection, which can become complex in non-trivial
cases. For example, the present class allows different objects
to be used for different rows (for example, if a subclass is indicated).
It allows computed fields to be set. And there's no need for
ResultSet columns to have the same names as bean properties.
The Pareto Principle in action: going the extra mile to automate
the extraction process makes the framework much more complex
and delivers little real benefit.
Subclasses can be constructed providing SQL, parameter types
and a DataSource. SQL will often vary between subclasses.
author: Rod Johnson author: Thomas Risberg author: Jean-Pierre Pawlak See Also: org.springframework.jdbc.object.MappingSqlQuery See Also: org.springframework.jdbc.object.SqlQuery |
Inner Class :protected class RowMapperImpl implements RowMapper | |
Method Summary | |
abstract protected Object | mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context) Subclasses must implement this method to convert each row
of the ResultSet into an object of the result type.
Parameters: rs - ResultSet we're working through Parameters: rowNum - row number (from 0) we're up to Parameters: parameters - to the query (passed to the execute() method).Subclasses are rarely interested in these.It can be null if there are no parameters. Parameters: context - passed to the execute() method.It can be null if no contextual information is need. | protected RowMapper | newRowMapper(Object[] parameters, Map context) Implementation of protected abstract method. |
MappingSqlQueryWithParameters | public MappingSqlQueryWithParameters()(Code) | | Constructor to allow use as a JavaBean
|
MappingSqlQueryWithParameters | public MappingSqlQueryWithParameters(DataSource ds, String sql)(Code) | | Convenient constructor with DataSource and SQL string.
Parameters: ds - DataSource to use to get connections Parameters: sql - SQL to run |
mapRow | abstract protected Object mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context) throws SQLException(Code) | | Subclasses must implement this method to convert each row
of the ResultSet into an object of the result type.
Parameters: rs - ResultSet we're working through Parameters: rowNum - row number (from 0) we're up to Parameters: parameters - to the query (passed to the execute() method).Subclasses are rarely interested in these.It can be null if there are no parameters. Parameters: context - passed to the execute() method.It can be null if no contextual information is need. an object of the result type throws: SQLException - if there's an error extracting data.Subclasses can simply not catch SQLExceptions, relying on theframework to clean up. |
newRowMapper | protected RowMapper newRowMapper(Object[] parameters, Map context)(Code) | | Implementation of protected abstract method. This invokes the subclass's
implementation of the mapRow() method.
|
Methods inherited from org.springframework.jdbc.object.SqlQuery | public List execute(Object[] params, Map context) throws DataAccessException(Code)(Java Doc) public List execute(Object[] params) throws DataAccessException(Code)(Java Doc) public List execute(Map context) throws DataAccessException(Code)(Java Doc) public List execute() throws DataAccessException(Code)(Java Doc) public List execute(int p1, Map context) throws DataAccessException(Code)(Java Doc) public List execute(int p1) throws DataAccessException(Code)(Java Doc) public List execute(int p1, int p2, Map context) throws DataAccessException(Code)(Java Doc) public List execute(int p1, int p2) throws DataAccessException(Code)(Java Doc) public List execute(long p1, Map context) throws DataAccessException(Code)(Java Doc) public List execute(long p1) throws DataAccessException(Code)(Java Doc) public List execute(String p1, Map context) throws DataAccessException(Code)(Java Doc) public List execute(String p1) throws DataAccessException(Code)(Java Doc) public List executeByNamedParam(Map paramMap, Map context) throws DataAccessException(Code)(Java Doc) public List executeByNamedParam(Map paramMap) throws DataAccessException(Code)(Java Doc) public Object findObject(Object[] params, Map context) throws DataAccessException(Code)(Java Doc) public Object findObject(Object[] params) throws DataAccessException(Code)(Java Doc) public Object findObject(int p1, Map context) throws DataAccessException(Code)(Java Doc) public Object findObject(int p1) throws DataAccessException(Code)(Java Doc) public Object findObject(int p1, int p2, Map context) throws DataAccessException(Code)(Java Doc) public Object findObject(int p1, int p2) throws DataAccessException(Code)(Java Doc) public Object findObject(long p1, Map context) throws DataAccessException(Code)(Java Doc) public Object findObject(long p1) throws DataAccessException(Code)(Java Doc) public Object findObject(String p1, Map context) throws DataAccessException(Code)(Java Doc) public Object findObject(String p1) throws DataAccessException(Code)(Java Doc) public Object findObjectByNamedParam(Map paramMap, Map context) throws DataAccessException(Code)(Java Doc) public Object findObjectByNamedParam(Map paramMap) throws DataAccessException(Code)(Java Doc) public int getRowsExpected()(Code)(Java Doc) abstract protected RowMapper newRowMapper(Object[] parameters, Map context)(Code)(Java Doc) public void setRowsExpected(int rowsExpected)(Code)(Java Doc)
|
Fields inherited from org.springframework.jdbc.object.RdbmsOperation | final protected Log logger(Code)(Java Doc)
|
|
|