Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.jdbc.core.simple
Class ParameterizedSingleColumnRowMapper<T>

    java.lang.Object
      org.springframework.jdbc.core.SingleColumnRowMapper
          org.springframework.jdbc.core.simple.ParameterizedSingleColumnRowMapper<T>

All Implemented Interfaces:
  RowMapper, ParameterizedRowMapper<T>

    public class ParameterizedSingleColumnRowMapper<T>

extends SingleColumnRowMapper
implements ParameterizedRowMapper<T>

`ParameterizedRowMapper` 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.

Uses Java 5 covariant return types to override the return type of the `mapRow(java.sql.ResultSet, int)` method to be the type parameter `T`.

Since:
  2.5.2
Author:
  Juergen Hoeller

Constructor Summary
`ParameterizedSingleColumnRowMapper()` Create a new ParameterizedSingleColumnRowMapper.

Method Summary
`T` | `mapRow(ResultSet rs, int rowNumber)` Extract a value for the single column in the current row.
`static
`<T> ParameterizedSingleColumnRowMapper<T>`
` | `newInstance(Class<T> requiredType)` Static factory method to create a new ParameterizedSingleColumnRowMapper (with the required type specified only once).

Methods inherited from class org.springframework.jdbc.core.SingleColumnRowMapper
`convertValueToRequiredType, getColumnValue, getColumnValue, setRequiredType`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ParameterizedSingleColumnRowMapper

    public ParameterizedSingleColumnRowMapper()

  Create a new ParameterizedSingleColumnRowMapper.

  Generally prefer the `newInstance(Class)` method instead, which avoids the need for specifying the mapped type twice.

  See Also:
    `SingleColumnRowMapper.setRequiredType(java.lang.Class)`

Method Detail

### mapRow

    public T mapRow(ResultSet rs,
                    int rowNumber)
             throws SQLException

  Description copied from class: `SingleColumnRowMapper`
  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.

  Specified by:
    `mapRow` in interface `RowMapper`
  Specified by:
    `mapRow` in interface `ParameterizedRowMapper<T>`
  Overrides:
    `mapRow` in class `SingleColumnRowMapper`
  Parameters:
    `rs` - the ResultSet to map (pre-initialized for the current row)
    `rowNumber` - the number of the current row
  Returns:
    the result object for the current row
  Throws:
    `SQLException` - if a SQLException is encountered getting column values (that is, there's no need to catch SQLException)
  See Also:
    `ResultSetMetaData.getColumnCount()`, `SingleColumnRowMapper.getColumnValue(java.sql.ResultSet, int, Class)`, `SingleColumnRowMapper.convertValueToRequiredType(Object, Class)`

### newInstance

    public static <T> ParameterizedSingleColumnRowMapper<T> newInstance(Class<T> requiredType)

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

  Parameters:
    `requiredType` - the type that each result object is expected to match

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2008 The Spring Framework.