Package org.springframework.jdbc.object

# Class GenericSqlQuery<T>

java.lang.Object
org.springframework.jdbc.object.RdbmsOperation
org.springframework.jdbc.object.SqlOperation
org.springframework.jdbc.object.SqlQuery<T>
org.springframework.jdbc.object.GenericSqlQuery<T>

Type Parameters:
  `T` - the result type

All Implemented Interfaces:
  `org.springframework.beans.factory.InitializingBean`

public class GenericSqlQuery<T> extends SqlQuery<T>
A concrete variant of `SqlQuery` which can be configured with a `RowMapper`.

Since:
  3.0
Author:
  Thomas Risberg, Juergen Hoeller
See Also:
  - `setRowMapper(org.springframework.jdbc.core.RowMapper<T>)`
  - `setRowMapperClass(java.lang.Class<? extends org.springframework.jdbc.core.RowMapper>)`

## Field Summary

### Fields inherited from class org.springframework.jdbc.object.RdbmsOperation

`logger`

## Constructor Summary

Constructors
Constructor
Description
`GenericSqlQuery()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
Ensures compilation if used in a bean factory.
`protected RowMapper<T>`
`newRowMapper(Object[] parameters, Map<?,?> context)`
Subclasses must implement this method to extract an object per row, to be returned by the `execute` method as an aggregated `List`.
`void`
`setRowMapper(RowMapper<T> rowMapper)`
Set a specific `RowMapper` instance to use for this query.
`void`
`setRowMapperClass(Class<? extends RowMapper> rowMapperClass)`
Set a `RowMapper` class for this query, creating a fresh `RowMapper` instance per execution.

### Methods inherited from class org.springframework.jdbc.object.SqlQuery

`execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, executeByNamedParam, executeByNamedParam, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObject, findObjectByNamedParam, findObjectByNamedParam, getRowsExpected, setRowsExpected`

### Methods inherited from class org.springframework.jdbc.object.SqlOperation

`compileInternal, getParsedSql, newPreparedStatementCreator, newPreparedStatementCreator, newPreparedStatementSetter, onCompileInternal`

### Methods inherited from class org.springframework.jdbc.object.RdbmsOperation

`allowsUnusedParameters, checkCompiled, compile, declareParameter, getDeclaredParameters, getGeneratedKeysColumnNames, getJdbcTemplate, getResultSetType, getSql, isCompiled, isReturnGeneratedKeys, isUpdatableResults, resolveSql, setDataSource, setFetchSize, setGeneratedKeysColumnNames, setJdbcTemplate, setMaxRows, setParameters, setQueryTimeout, setResultSetType, setReturnGeneratedKeys, setSql, setTypes, setUpdatableResults, supportsLobParameters, validateNamedParameters, validateParameters`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### GenericSqlQuery

public GenericSqlQuery()

## Method Details

### setRowMapper

public void setRowMapper(RowMapper<T> rowMapper)
Set a specific `RowMapper` instance to use for this query.

Since:
  4.3.2

### setRowMapperClass

public void setRowMapperClass(Class<? extends RowMapper> rowMapperClass)
Set a `RowMapper` class for this query, creating a fresh `RowMapper` instance per execution.

### afterPropertiesSet

public void afterPropertiesSet()
Description copied from class: `RdbmsOperation`
Ensures compilation if used in a bean factory.

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Overrides:
  `afterPropertiesSet` in class `RdbmsOperation`

### newRowMapper

protected RowMapper<T> newRowMapper(@Nullable Object[] parameters, @Nullable Map<?,?> context)
Description copied from class: `SqlQuery`
Subclasses must implement this method to extract an object per row, to be returned by the `execute` method as an aggregated `List`.

Specified by:
  `newRowMapper` in class `SqlQuery<T>`
Parameters:
  `parameters` - the parameters to the `execute()` method, in case subclass is interested; may be `null` if there were no parameters.
  `context` - the 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.
See Also:
  - `SqlQuery.execute(java.lang.Object[], java.util.Map<?, ?>)`