spring-framework / org.springframework.jdbc.core.namedparam / NamedParameterJdbcOperations / query

query

@Nullable abstract fun <T : Any> query(sql: String, paramSource: SqlParameterSource, rse: ResultSetExtractor<T>): T

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet with a ResultSetExtractor.

Parameters

sql - SQL query to execute

paramSource - container of arguments to bind to the query

rse - object that will extract results

Exceptions

DataAccessException - if the query fails

Return
an arbitrary result object, as returned by the ResultSetExtractor

@Nullable abstract fun <T : Any> query(sql: String, paramMap: MutableMap<String, *>, rse: ResultSetExtractor<T>): T

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet with a ResultSetExtractor.

Parameters

sql - SQL query to execute

paramMap - map of parameters to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)

rse - object that will extract results

Exceptions

org.springframework.dao.DataAccessException - if the query fails

Return
an arbitrary result object, as returned by the ResultSetExtractor

@Nullable abstract fun <T : Any> query(sql: String, rse: ResultSetExtractor<T>): T

Query given SQL to create a prepared statement from SQL, reading the ResultSet with a ResultSetExtractor.

Note: In contrast to the JdbcOperations method with the same signature, this query variant always uses a PreparedStatement. It is effectively equivalent to a query call with an empty parameter Map.

Parameters

sql - SQL query to execute

rse - object that will extract results

Exceptions

org.springframework.dao.DataAccessException - if the query fails

Return
an arbitrary result object, as returned by the ResultSetExtractor

abstract fun query(sql: String, paramSource: SqlParameterSource, rch: RowCallbackHandler): Unit

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet on a per-row basis with a RowCallbackHandler.

Parameters

sql - SQL query to execute

paramSource - container of arguments to bind to the query

rch - object that will extract results, one row at a time

Exceptions

DataAccessException - if the query fails

abstract fun query(sql: String, paramMap: MutableMap<String, *>, rch: RowCallbackHandler): Unit

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet on a per-row basis with a RowCallbackHandler.

Parameters

sql - SQL query to execute

paramMap - map of parameters to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)

rch - object that will extract results, one row at a time

Exceptions

org.springframework.dao.DataAccessException - if the query fails

abstract fun query(sql: String, rch: RowCallbackHandler): Unit

Query given SQL to create a prepared statement from SQL, reading the ResultSet on a per-row basis with a RowCallbackHandler.

Note: In contrast to the JdbcOperations method with the same signature, this query variant always uses a PreparedStatement. It is effectively equivalent to a query call with an empty parameter Map.

Parameters

sql - SQL query to execute

rch - object that will extract results, one row at a time

Exceptions

org.springframework.dao.DataAccessException - if the query fails

abstract fun <T : Any> query(sql: String, paramSource: SqlParameterSource, rowMapper: RowMapper<T>): MutableList<T>

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper.

Parameters

sql - SQL query to execute

paramSource - container of arguments to bind to the query

rowMapper - object that will map one object per row

Exceptions

org.springframework.dao.DataAccessException - if the query fails

Return
the result List, containing mapped objects

abstract fun <T : Any> query(sql: String, paramMap: MutableMap<String, *>, rowMapper: RowMapper<T>): MutableList<T>

Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper.

Parameters

sql - SQL query to execute

paramMap - map of parameters to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)

rowMapper - object that will map one object per row

Exceptions

org.springframework.dao.DataAccessException - if the query fails

Return
the result List, containing mapped objects

abstract fun <T : Any> query(sql: String, rowMapper: RowMapper<T>): MutableList<T>

Query given SQL to create a prepared statement from SQL, mapping each row to a Java object via a RowMapper.

Note: In contrast to the JdbcOperations method with the same signature, this query variant always uses a PreparedStatement. It is effectively equivalent to a query call with an empty parameter Map.

Parameters

sql - SQL query to execute

rowMapper - object that will map one object per row

Exceptions

org.springframework.dao.DataAccessException - if the query fails

Return
the result List, containing mapped objects