Top Description Constructors Methods
org.springframework.jdbc.object

public abstract Class MappingSqlQuery<T>

extends MappingSqlQueryWithParameters<T>
Class Inheritance
Known Direct Subclasses
org.springframework.jdbc.object.SqlFunction
Type Parameters
<T>
the result type
Imports
java.sql.ResultSet, .SQLException, java.util.Map, javax.sql.DataSource, org.springframework.lang.Nullable

Reusable query in which concrete subclasses must implement the abstract mapRow(ResultSet, int) method to convert each row of the JDBC ResultSet into an object.

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.

Authors
Rod Johnson, Thomas Risberg, Jean-Pierre Pawlak
See Also
MappingSqlQueryWithParameters

Constructor Summary

AccessConstructor and Description
public
MappingSqlQuery()

Constructor that allows use as a JavaBean.

public
MappingSqlQuery(DataSource
the DataSource to use to obtain connections
ds
,
String
the SQL to run
sql
)

Convenient constructor with DataSource and SQL string.

Method Summary

Modifier and TypeMethod and Description
protected final T
mapRow(ResultSet
the ResultSet we're working through
rs
,
int
row number (from 0) we're up to
rowNum
,
Object[]
to the query (passed to the execute() method). Subclasses are rarely interested in these. It can be null if there are no parameters.
parameters
,
Map<?, ?>
passed to the execute() method. It can be null if no contextual information is need.
context
)

Implements abstract org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

This method is implemented to invoke the simpler mapRow template method, ignoring parameters.

protected abstract T

Returns:

an object of the result type
mapRow
(ResultSet
the ResultSet we're working through
rs
,
int
row number (from 0) we're up to
rowNum
)

Subclasses must implement this method to convert each row of the ResultSet into an object of the result type.

Inherited from org.springframework.jdbc.object.MappingSqlQueryWithParameters:
newRowMapper

Constructor Detail

MappingSqlQueryback to summary
public MappingSqlQuery()

Constructor that allows use as a JavaBean.

MappingSqlQueryback to summary
public MappingSqlQuery(DataSource ds, String sql)

Convenient constructor with DataSource and SQL string.

Parameters
ds:DataSource

the DataSource to use to obtain connections

sql:String

the SQL to run

Method Detail

mapRowback to summary
protected final T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map<?, ?> context) throws SQLException

Implements abstract org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

This method is implemented to invoke the simpler mapRow template method, ignoring parameters.

Parameters
rs:ResultSet

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

the ResultSet we're working through

rowNum:int

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

row number (from 0) we're up to

parameters:Object[]

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

to the query (passed to the execute() method). Subclasses are rarely interested in these. It can be null if there are no parameters.

context:Map<?, ?>

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

passed to the execute() method. It can be null if no contextual information is need.

Returns:T

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

an object of the result type

Annotations
@Override
@Nullable
Exceptions
SQLException:

Doc from org.springframework.jdbc.object.MappingSqlQueryWithParameters.mapRow.

if there's an error extracting data. Subclasses can simply not catch SQLExceptions, relying on the framework to clean up.

See Also
mapRow(ResultSet, int)
mapRowback to summary
protected abstract T mapRow(ResultSet rs, int rowNum) throws SQLException

Subclasses must implement this method to convert each row of the ResultSet into an object of the result type.

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.

Parameters
rs:ResultSet

the ResultSet we're working through

rowNum:int

row number (from 0) we're up to

Returns:T

an object of the result type

Annotations
@Nullable
Exceptions
SQLException:
if there's an error extracting data. Subclasses can simply not catch SQLExceptions, relying on the framework to clean up.