spring-framework / org.springframework.jdbc.core / SingleColumnRowMapper

SingleColumnRowMapper

open class SingleColumnRowMapper<T : Any> : RowMapper<T>

RowMapper implementation that converts a single column into a single result value per row. Expects to operate on a java.sql.ResultSet that just contains a single column.

The type of the result value for each row can be specified. The value for the single column will be extracted from the ResultSet and converted into the specified target type.

Author
Juergen Hoeller

Since
1.2

See Also
JdbcTemplate#queryForList(String, Class)JdbcTemplate#queryForObject(String, Class)

Constructors

<init>

SingleColumnRowMapper()

Create a new SingleColumnRowMapper for bean-style configuration.

SingleColumnRowMapper(requiredType: Class<T>)

Create a new SingleColumnRowMapper.

Consider using the #newInstance factory method instead, which allows for specifying the required type once only.

Functions

mapRow

open fun mapRow(rs: ResultSet, rowNum: Int): T

Extract a value for the single column in the current row.

Validates that there is only one column selected, then delegates to getColumnValue() and also convertValueToRequiredType, if necessary.

newInstance

open static fun <T : Any> newInstance(requiredType: Class<T>): SingleColumnRowMapper<T>

Static factory method to create a new SingleColumnRowMapper (with the required type specified only once).

setRequiredType

open fun setRequiredType(requiredType: Class<T>): Unit

Set the type that each result object is expected to match.

If not specified, the column value will be exposed as returned by the JDBC driver.