spring-framework / org.springframework.jdbc.object / MappingSqlQuery

MappingSqlQuery

abstract class MappingSqlQuery<T : Any> : MappingSqlQueryWithParameters<T>

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.

Author
Rod Johnson

Author
Thomas Risberg

Author
Jean-Pierre Pawlak

See Also
MappingSqlQueryWithParameters

Constructors

<init>

MappingSqlQuery()

Constructor that allows use as a JavaBean.

MappingSqlQuery(ds: DataSource, sql: String)

Convenient constructor with DataSource and SQL string.

Inheritors

SqlFunction

open class SqlFunction<T : Any> : MappingSqlQuery<T>

SQL "function" wrapper for a query that returns a single row of results. The default behavior is to return an int, but that can be overridden by using the constructor with an extra return type parameter.

Intended to use to call SQL functions that return a single result using a query like "select user()" or "select sysdate from dual". It is not intended for calling more complex stored functions or for using a CallableStatement to invoke a stored procedure or stored function. Use StoredProcedure or SqlCall for this type of processing.

This is a concrete class, which there is often no need to subclass. Code using this package can create an object of this type, declaring SQL and parameters, and then invoke the appropriate run method repeatedly to execute the function. Subclasses are only supposed to add specialized run methods for specific parameter and return types.

Like all RdbmsOperation objects, SqlFunction objects are thread-safe.