java.lang.Object | |||
↳ | org.springframework.jdbc.object.RdbmsOperation | ||
↳ | org.springframework.jdbc.object.SqlOperation | ||
↳ | org.springframework.jdbc.object.SqlQuery<T> |
Known Direct Subclasses |
Known Indirect Subclasses
MappingSqlQuery<T>,
SqlFunction<T>
|
Reusable operation object representing a SQL query.
Subclasses must implement the newRowMapper(Object[], Map)
method to provide
an object that can extract the results of iterating over the
ResultSet
created during the execution of the query.
This class provides a number of public execute
methods that are
analogous to the different convenient JDO query execute methods. Subclasses
can either rely on one of these inherited methods, or can add their own
custom execution methods, with meaningful names and typed parameters
(definitely a best practice). Each custom query method will invoke one of
this class's untyped query methods.
Like all RdbmsOperation
classes that ship with the Spring
Framework, SqlQuery
instances are thread-safe after their
initialization is complete. That is, after they are constructed and configured
via their setter methods, they can be used safely from multiple threads.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.object.RdbmsOperation
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor to allow use as a JavaBean.
| |||||||||||
Convenient constructor with a
DataSource and SQL string. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Convenient method to execute with a single String parameter.
| |||||||||||
Convenient method to execute with a single long parameter.
| |||||||||||
Convenient method to execute with two int parameters.
| |||||||||||
Convenient method to execute without parameters nor context.
| |||||||||||
Convenient method to execute with a single int parameter and context.
| |||||||||||
Convenient method to execute without parameters.
| |||||||||||
Convenient method to execute with a single String parameter and context.
| |||||||||||
Convenient method to execute with a single int parameter.
| |||||||||||
Convenient method to execute without context.
| |||||||||||
Convenient method to execute with two int parameters and context.
| |||||||||||
Central execution method.
| |||||||||||
Convenient method to execute with a single long parameter and context.
| |||||||||||
Convenient method to execute without context.
| |||||||||||
Central execution method.
| |||||||||||
Convenient method to find a single object given a single int parameter.
| |||||||||||
Generic object finder method, used by all other
findObject methods. | |||||||||||
Convenient method to find a single object given a single int parameter
and a context.
| |||||||||||
Convenient method to find a single object given a single String parameter
and a context.
| |||||||||||
Convenient method to find a single object without context.
| |||||||||||
Convenient method to find a single object given a single long parameter
and a context.
| |||||||||||
Convenient method to find a single object given two int parameters
and a context.
| |||||||||||
Convenient method to find a single object given a single long parameter.
| |||||||||||
Convenient method to find a single object given two int parameters.
| |||||||||||
Convenient method to find a single object given a single String parameter.
| |||||||||||
Generic object finder method for named parameters.
| |||||||||||
Convenient method to execute without context.
| |||||||||||
Get the number of rows expected.
| |||||||||||
Set the number of rows expected.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Subclasses must implement this method to extract an object per row, to be
returned by the
List . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.object.SqlOperation
| |||||||||||
From class
org.springframework.jdbc.object.RdbmsOperation
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
|
Constructor to allow use as a JavaBean.
The DataSource
and SQL must be supplied before
compilation and use.
Convenient constructor with a DataSource
and SQL string.
ds | the DataSource to use to get connections |
---|---|
sql | the SQL to execute; SQL can also be supplied at runtime
by overriding the getSql() method.
|
Convenient method to execute with a single String parameter.
p1 | single String parameter |
---|
DataAccessException |
---|
Convenient method to execute with a single long parameter.
p1 | single long parameter |
---|
DataAccessException |
---|
Convenient method to execute with two int parameters.
p1 | first int parameter |
---|---|
p2 | second int parameter |
DataAccessException |
---|
Convenient method to execute without parameters nor context.
DataAccessException |
---|
Convenient method to execute with a single int parameter and context.
p1 | single int parameter |
---|---|
context | the contextual information for object creation |
DataAccessException |
---|
Convenient method to execute without parameters.
context | the contextual information for object creation |
---|
DataAccessException |
---|
Convenient method to execute with a single String parameter and context.
p1 | single String parameter |
---|---|
context | the contextual information for object creation |
DataAccessException |
---|
Convenient method to execute with a single int parameter.
p1 | single int parameter |
---|
DataAccessException |
---|
Convenient method to execute without context.
params | parameters for the query. Primitive parameters must be represented by their Object wrapper type. The ordering of parameters is significant. |
---|
DataAccessException |
---|
Convenient method to execute with two int parameters and context.
p1 | first int parameter |
---|---|
p2 | second int parameter |
context | the contextual information for object creation |
DataAccessException |
---|
Central execution method. All un-named parameter execution goes through this method.
params | parameters, similar to JDO query parameters. Primitive parameters must be represented by their Object wrapper type. The ordering of parameters is significant. |
---|---|
context | contextual information passed to the mapRow
callback method. The JDBC operation itself doesn't rely on this parameter,
but it can be useful for creating the objects of the result list. |
DataAccessException |
---|
Convenient method to execute with a single long parameter and context.
p1 | single long parameter |
---|---|
context | the contextual information for object creation |
DataAccessException |
---|
Convenient method to execute without context.
paramMap | parameters associated with the name specified while declaring the SqlParameters. Primitive parameters must be represented by their Object wrapper type. The ordering of parameters is not significant. |
---|
DataAccessException |
---|
Central execution method. All named parameter execution goes through this method.
paramMap | parameters associated with the name specified while declaring the SqlParameters. Primitive parameters must be represented by their Object wrapper type. The ordering of parameters is not significant since they are supplied in a SqlParameterMap which is an implementation of the Map interface. |
---|---|
context | contextual information passed to the mapRow
callback method. The JDBC operation itself doesn't rely on this parameter,
but it can be useful for creating the objects of the result list. |
DataAccessException |
---|
Convenient method to find a single object given a single int parameter.
DataAccessException |
---|
Generic object finder method, used by all other findObject
methods.
Object finder methods are like EJB entity bean finders, in that it is
considered an error if they return more than one result.
null
if not found. Subclasses may
choose to treat this as an error and throw an exception.DataAccessException |
---|
Convenient method to find a single object given a single int parameter and a context.
DataAccessException |
---|
Convenient method to find a single object given a single String parameter and a context.
DataAccessException |
---|
Convenient method to find a single object without context.
DataAccessException |
---|
Convenient method to find a single object given a single long parameter and a context.
DataAccessException |
---|
Convenient method to find a single object given two int parameters and a context.
DataAccessException |
---|
Convenient method to find a single object given a single long parameter.
DataAccessException |
---|
Convenient method to find a single object given two int parameters.
DataAccessException |
---|
Convenient method to find a single object given a single String parameter.
DataAccessException |
---|
Generic object finder method for named parameters.
paramMap | Map of parameter name to parameter object, matching named parameters specified in the SQL statement. Ordering is not significant. |
---|---|
context | contextual information passed to the mapRow
callback method. The JDBC operation itself doesn't rely on this parameter,
but it can be useful for creating the objects of the result list. |
DataAccessException |
---|
Convenient method to execute without context.
paramMap | Map of parameter name to parameter object, matching named parameters specified in the SQL statement. Ordering is not significant. |
---|
DataAccessException |
---|
Get the number of rows expected.
Set the number of rows expected.
This can be used to ensure efficient storage of results. The default behavior is not to expect any specific number of rows.
Subclasses must implement this method to extract an object per row, to be
returned by the List
.
parameters | the parameters to the execute() method,
in case subclass is interested; may be null if there
were no parameters. |
---|---|
context | contextual information passed to the mapRow
callback method. The JDBC operation itself doesn't rely on this parameter,
but it can be useful for creating the objects of the result list. |