|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2002-2018 the original author or authors.
|
|
|
|
|
* Copyright 2002-2019 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -54,10 +54,10 @@ public interface JdbcOperations {
|
|
|
|
|
* data access operations, within Spring's managed JDBC environment:
|
|
|
|
|
* that is, participating in Spring-managed transactions and converting
|
|
|
|
|
* JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* @param action the callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param action a callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
@ -74,10 +74,10 @@ public interface JdbcOperations {
|
|
|
|
|
* access operations on a single Statement, within Spring's managed JDBC
|
|
|
|
|
* environment: that is, participating in Spring-managed transactions and
|
|
|
|
|
* converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* @param action callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param action a callback that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
@ -97,7 +97,7 @@ public interface JdbcOperations {
|
|
|
|
|
* execute a static query with a PreparedStatement, use the overloaded
|
|
|
|
|
* {@code query} method with {@code null} as argument array.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rse object that will extract all rows of results
|
|
|
|
|
* @param rse a callback that will extract all rows of results
|
|
|
|
|
* @return an arbitrary result object, as returned by the ResultSetExtractor
|
|
|
|
|
* @throws DataAccessException if there is any problem executing the query
|
|
|
|
|
* @see #query(String, Object[], ResultSetExtractor)
|
|
|
|
@ -112,20 +112,20 @@ public interface JdbcOperations {
|
|
|
|
|
* execute a static query with a PreparedStatement, use the overloaded
|
|
|
|
|
* {@code query} method with {@code null} as argument array.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @throws DataAccessException if there is any problem executing the query
|
|
|
|
|
* @see #query(String, Object[], RowCallbackHandler)
|
|
|
|
|
*/
|
|
|
|
|
void query(String sql, RowCallbackHandler rch) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute a query given static SQL, mapping each row to a Java object
|
|
|
|
|
* Execute a query given static SQL, mapping each row to a result object
|
|
|
|
|
* via a RowMapper.
|
|
|
|
|
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
|
|
|
|
|
* execute a static query with a PreparedStatement, use the overloaded
|
|
|
|
|
* {@code query} method with {@code null} as argument array.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the result List, containing mapped objects
|
|
|
|
|
* @throws DataAccessException if there is any problem executing the query
|
|
|
|
|
* @see #query(String, Object[], RowMapper)
|
|
|
|
@ -133,14 +133,14 @@ public interface JdbcOperations {
|
|
|
|
|
<T> List<T> query(String sql, RowMapper<T> rowMapper) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute a query given static SQL, mapping a single result row to a Java
|
|
|
|
|
* object via a RowMapper.
|
|
|
|
|
* Execute a query given static SQL, mapping a single result row to a
|
|
|
|
|
* result object via a RowMapper.
|
|
|
|
|
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
|
|
|
|
|
* execute a static query with a PreparedStatement, use the overloaded
|
|
|
|
|
* {@link #queryForObject(String, RowMapper, Object...)} method with
|
|
|
|
|
* {@code null} as argument array.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the single mapped object (may be {@code null} if the given
|
|
|
|
|
* {@link RowMapper} returned {@code} null)
|
|
|
|
|
* @throws IncorrectResultSizeDataAccessException if the query does not
|
|
|
|
@ -172,7 +172,7 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T queryForObject(String sql, Class<T> requiredType) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute a query for a result Map, given static SQL.
|
|
|
|
|
* Execute a query for a result map, given static SQL.
|
|
|
|
|
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
|
|
|
|
|
* execute a static query with a PreparedStatement, use the overloaded
|
|
|
|
|
* {@link #queryForMap(String, Object...)} method with {@code null}
|
|
|
|
@ -180,8 +180,7 @@ public interface JdbcOperations {
|
|
|
|
|
* <p>The query is expected to be a single row query; the result row will be
|
|
|
|
|
* mapped to a Map (one entry for each column, using the column name as the key).
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @return the result Map (one entry for each column, using the
|
|
|
|
|
* column name as the key)
|
|
|
|
|
* @return the result Map (one entry per column, with column name as key)
|
|
|
|
|
* @throws IncorrectResultSizeDataAccessException if the query does not
|
|
|
|
|
* return exactly one row
|
|
|
|
|
* @throws DataAccessException if there is any problem executing the query
|
|
|
|
@ -215,7 +214,7 @@ public interface JdbcOperations {
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* Maps (one entry for each column using the column name as the key).
|
|
|
|
|
* Each element in the list will be of the form returned by this interface's
|
|
|
|
|
* queryForMap() methods.
|
|
|
|
|
* {@code queryForMap} methods.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @return an List that contains a Map per row
|
|
|
|
|
* @throws DataAccessException if there is any problem executing the query
|
|
|
|
@ -270,14 +269,14 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Execute a JDBC data access operation, implemented as callback action
|
|
|
|
|
* working on a JDBC PreparedStatement. This allows for implementing arbitrary
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed
|
|
|
|
|
* JDBC environment: that is, participating in Spring-managed transactions
|
|
|
|
|
* and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* @param psc object that can create a PreparedStatement given a Connection
|
|
|
|
|
* @param action callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed JDBC
|
|
|
|
|
* environment: that is, participating in Spring-managed transactions and
|
|
|
|
|
* converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param psc a callback that creates a PreparedStatement given a Connection
|
|
|
|
|
* @param action a callback that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
@ -286,26 +285,25 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Execute a JDBC data access operation, implemented as callback action
|
|
|
|
|
* working on a JDBC PreparedStatement. This allows for implementing arbitrary
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed
|
|
|
|
|
* JDBC environment: that is, participating in Spring-managed transactions
|
|
|
|
|
* and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed JDBC
|
|
|
|
|
* environment: that is, participating in Spring-managed transactions and
|
|
|
|
|
* converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param sql the SQL to execute
|
|
|
|
|
* @param action callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* @param action a callback that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
<T> T execute(String sql, PreparedStatementCallback<T> action) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet with a
|
|
|
|
|
* ResultSetExtractor.
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet with a ResultSetExtractor.
|
|
|
|
|
* <p>A PreparedStatementCreator can either be implemented directly or
|
|
|
|
|
* configured through a PreparedStatementCreatorFactory.
|
|
|
|
|
* @param psc object that can create a PreparedStatement given a Connection
|
|
|
|
|
* @param rse object that will extract results
|
|
|
|
|
* @param psc a callback that creates a PreparedStatement given a Connection
|
|
|
|
|
* @param rse a callback that will extract results
|
|
|
|
|
* @return an arbitrary result object, as returned by the ResultSetExtractor
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
* @see PreparedStatementCreatorFactory
|
|
|
|
@ -314,14 +312,13 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T query(PreparedStatementCreator psc, ResultSetExtractor<T> rse) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet with a
|
|
|
|
|
* ResultSetExtractor.
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet with a ResultSetExtractor.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param pss object that knows how to set values on the prepared statement.
|
|
|
|
|
* @param pss a callback that knows how to set values on the prepared statement.
|
|
|
|
|
* If this is {@code null}, the SQL will be assumed to contain no bind parameters.
|
|
|
|
|
* Even if there are no bind parameters, this object may be used to
|
|
|
|
|
* set fetch size and other performance options.
|
|
|
|
|
* @param rse object that will extract results
|
|
|
|
|
* Even if there are no bind parameters, this callback may be used to set the
|
|
|
|
|
* fetch size and other performance options.
|
|
|
|
|
* @param rse a callback that will extract results
|
|
|
|
|
* @return an arbitrary result object, as returned by the ResultSetExtractor
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
@ -329,14 +326,13 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T query(String sql, @Nullable PreparedStatementSetter pss, ResultSetExtractor<T> rse) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
* 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.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
|
* (constants from {@code java.sql.Types})
|
|
|
|
|
* @param rse object that will extract results
|
|
|
|
|
* @param rse a callback that will extract results
|
|
|
|
|
* @return an arbitrary result object, as returned by the ResultSetExtractor
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
* @see java.sql.Types
|
|
|
|
@ -345,15 +341,14 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T query(String sql, Object[] args, int[] argTypes, ResultSetExtractor<T> rse) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
* 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.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
|
* only the argument value but also the SQL type and optionally the scale
|
|
|
|
|
* @param rse object that will extract results
|
|
|
|
|
* @param rse a callback that will extract results
|
|
|
|
|
* @return an arbitrary result object, as returned by the ResultSetExtractor
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
*/
|
|
|
|
@ -361,11 +356,10 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T query(String sql, Object[] args, ResultSetExtractor<T> rse) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
* 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.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rse object that will extract results
|
|
|
|
|
* @param rse a callback that will extract results
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
@ -378,12 +372,12 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T query(String sql, ResultSetExtractor<T> rse, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet on a per-row
|
|
|
|
|
* basis with a RowCallbackHandler.
|
|
|
|
|
* Query using a prepared statement, reading the ResultSet on a per-row basis
|
|
|
|
|
* with a RowCallbackHandler.
|
|
|
|
|
* <p>A PreparedStatementCreator can either be implemented directly or
|
|
|
|
|
* configured through a PreparedStatementCreatorFactory.
|
|
|
|
|
* @param psc object that can create a PreparedStatement given a Connection
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* @param psc a callback that creates a PreparedStatement given a Connection
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
* @see PreparedStatementCreatorFactory
|
|
|
|
|
*/
|
|
|
|
@ -391,15 +385,14 @@ public interface JdbcOperations {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* PreparedStatementSetter implementation that knows how to bind values
|
|
|
|
|
* to the query, reading the ResultSet on a per-row basis with a
|
|
|
|
|
* RowCallbackHandler.
|
|
|
|
|
* PreparedStatementSetter implementation that knows how to bind values to the
|
|
|
|
|
* query, reading the ResultSet on a per-row basis with a RowCallbackHandler.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param pss object that knows how to set values on the prepared statement.
|
|
|
|
|
* @param pss a callback that knows how to set values on the prepared statement.
|
|
|
|
|
* If this is {@code null}, the SQL will be assumed to contain no bind parameters.
|
|
|
|
|
* Even if there are no bind parameters, this object may be used to
|
|
|
|
|
* set fetch size and other performance options.
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* Even if there are no bind parameters, this callback may be used to set the
|
|
|
|
|
* fetch size and other performance options.
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
*/
|
|
|
|
|
void query(String sql, @Nullable PreparedStatementSetter pss, RowCallbackHandler rch) throws DataAccessException;
|
|
|
|
@ -412,7 +405,7 @@ public interface JdbcOperations {
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
|
* (constants from {@code java.sql.Types})
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
* @see java.sql.Types
|
|
|
|
|
*/
|
|
|
|
@ -427,7 +420,7 @@ public interface JdbcOperations {
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
|
* only the argument value but also the SQL type and optionally the scale
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
*/
|
|
|
|
|
void query(String sql, Object[] args, RowCallbackHandler rch) throws DataAccessException;
|
|
|
|
@ -437,7 +430,7 @@ public interface JdbcOperations {
|
|
|
|
|
* arguments to bind to the query, reading the ResultSet on a per-row basis
|
|
|
|
|
* with a RowCallbackHandler.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rch object that will extract results, one row at a time
|
|
|
|
|
* @param rch a callback that will extract results, one row at a time
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
@ -448,12 +441,12 @@ public interface JdbcOperations {
|
|
|
|
|
void query(String sql, RowCallbackHandler rch, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query using a prepared statement, mapping each row to a Java object
|
|
|
|
|
* Query using a prepared statement, mapping each row to a result object
|
|
|
|
|
* via a RowMapper.
|
|
|
|
|
* <p>A PreparedStatementCreator can either be implemented directly or
|
|
|
|
|
* configured through a PreparedStatementCreatorFactory.
|
|
|
|
|
* @param psc object that can create a PreparedStatement given a Connection
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param psc a callback that creates a PreparedStatement given a Connection
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the result List, containing mapped objects
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
* @see PreparedStatementCreatorFactory
|
|
|
|
@ -463,27 +456,27 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* PreparedStatementSetter implementation that knows how to bind values
|
|
|
|
|
* to the query, mapping each row to a Java object via a RowMapper.
|
|
|
|
|
* to the query, mapping each row to a result object via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param pss object that knows how to set values on the prepared statement.
|
|
|
|
|
* @param pss a callback that knows how to set values on the prepared statement.
|
|
|
|
|
* If this is {@code null}, the SQL will be assumed to contain no bind parameters.
|
|
|
|
|
* Even if there are no bind parameters, this object may be used to
|
|
|
|
|
* set fetch size and other performance options.
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* Even if there are no bind parameters, this callback may be used to set the
|
|
|
|
|
* fetch size and other performance options.
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the result List, containing mapped objects
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
*/
|
|
|
|
|
<T> List<T> query(String sql, @Nullable PreparedStatementSetter pss, RowMapper<T> rowMapper) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* 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 result object
|
|
|
|
|
* via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
|
* (constants from {@code java.sql.Types})
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the result List, containing mapped objects
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
* @see java.sql.Types
|
|
|
|
@ -491,26 +484,26 @@ public interface JdbcOperations {
|
|
|
|
|
<T> List<T> query(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* 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 result object
|
|
|
|
|
* via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
|
* only the argument value but also the SQL type and optionally the scale
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the result List, containing mapped objects
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
|
*/
|
|
|
|
|
<T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* 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 result object
|
|
|
|
|
* via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
@ -524,13 +517,13 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list
|
|
|
|
|
* of arguments to bind to the query, mapping a single result row to a
|
|
|
|
|
* Java object via a RowMapper.
|
|
|
|
|
* result object via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type)
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
|
* (constants from {@code java.sql.Types})
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the single mapped object (may be {@code null} if the given
|
|
|
|
|
* {@link RowMapper} returned {@code} null)
|
|
|
|
|
* @throws IncorrectResultSizeDataAccessException if the query does not
|
|
|
|
@ -544,13 +537,13 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list
|
|
|
|
|
* of arguments to bind to the query, mapping a single result row to a
|
|
|
|
|
* Java object via a RowMapper.
|
|
|
|
|
* result object via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
|
* only the argument value but also the SQL type and optionally the scale
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @return the single mapped object (may be {@code null} if the given
|
|
|
|
|
* {@link RowMapper} returned {@code} null)
|
|
|
|
|
* @throws IncorrectResultSizeDataAccessException if the query does not
|
|
|
|
@ -563,9 +556,9 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list
|
|
|
|
|
* of arguments to bind to the query, mapping a single result row to a
|
|
|
|
|
* Java object via a RowMapper.
|
|
|
|
|
* result object via a RowMapper.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param rowMapper object that will map one object per row
|
|
|
|
|
* @param rowMapper a callback that will map one object per row
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
|
* may also contain {@link SqlParameterValue} objects which indicate not
|
|
|
|
@ -581,8 +574,8 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T queryForObject(String sql, RowMapper<T> rowMapper, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result object.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result object.
|
|
|
|
|
* <p>The query is expected to be a single row/single column query; the returned
|
|
|
|
|
* result will be directly mapped to the corresponding object type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -602,8 +595,8 @@ public interface JdbcOperations {
|
|
|
|
|
throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result object.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result object.
|
|
|
|
|
* <p>The query is expected to be a single row/single column query; the returned
|
|
|
|
|
* result will be directly mapped to the corresponding object type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -622,8 +615,8 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T queryForObject(String sql, Object[] args, Class<T> requiredType) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result object.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result object.
|
|
|
|
|
* <p>The query is expected to be a single row/single column query; the returned
|
|
|
|
|
* result will be directly mapped to the corresponding object type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -643,16 +636,15 @@ public interface JdbcOperations {
|
|
|
|
|
<T> T queryForObject(String sql, Class<T> requiredType, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result Map.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result map.
|
|
|
|
|
* <p>The query is expected to be a single row query; the result row will be
|
|
|
|
|
* mapped to a Map (one entry for each column, using the column name as the key).
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
|
* (constants from {@code java.sql.Types})
|
|
|
|
|
* @return the result Map (one entry for each column, using the
|
|
|
|
|
* column name as the key)
|
|
|
|
|
* @return the result Map (one entry per column, with column name as key)
|
|
|
|
|
* @throws IncorrectResultSizeDataAccessException if the query does not
|
|
|
|
|
* return exactly one row
|
|
|
|
|
* @throws DataAccessException if the query fails
|
|
|
|
@ -663,11 +655,11 @@ public interface JdbcOperations {
|
|
|
|
|
Map<String, Object> queryForMap(String sql, Object[] args, int[] argTypes) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result Map.
|
|
|
|
|
* The queryForMap() methods defined by this interface are appropriate
|
|
|
|
|
* when you don't have a domain model. Otherwise, consider using
|
|
|
|
|
* one of the queryForObject() methods.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result map.
|
|
|
|
|
* <p>The {@code queryForMap} methods defined by this interface are appropriate
|
|
|
|
|
* when you don't have a domain model. Otherwise, consider using one of the
|
|
|
|
|
* {@code queryForObject} methods.
|
|
|
|
|
* <p>The query is expected to be a single row query; the result row will be
|
|
|
|
|
* mapped to a Map (one entry for each column, using the column name as the key).
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -686,8 +678,8 @@ public interface JdbcOperations {
|
|
|
|
|
Map<String, Object> queryForMap(String sql, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result list.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result list.
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* result objects, each of them matching the specified element type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -701,12 +693,12 @@ public interface JdbcOperations {
|
|
|
|
|
* @see #queryForList(String, Class)
|
|
|
|
|
* @see SingleColumnRowMapper
|
|
|
|
|
*/
|
|
|
|
|
<T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elementType)
|
|
|
|
|
<T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elementType)
|
|
|
|
|
throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result list.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result list.
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* result objects, each of them matching the specified element type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -724,8 +716,8 @@ public interface JdbcOperations {
|
|
|
|
|
<T> List<T> queryForList(String sql, Object[] args, Class<T> elementType) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result list.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result list.
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* result objects, each of them matching the specified element type.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
@ -744,12 +736,12 @@ public interface JdbcOperations {
|
|
|
|
|
<T> List<T> queryForList(String sql, Class<T> elementType, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result list.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result list.
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* Maps (one entry for each column, using the column name as the key).
|
|
|
|
|
* Thus Each element in the list will be of the form returned by this interface's
|
|
|
|
|
* queryForMap() methods.
|
|
|
|
|
* Each element in the list will be of the form returned by this interface's
|
|
|
|
|
* {@code queryForMap} methods.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* @param argTypes the SQL types of the arguments
|
|
|
|
@ -762,12 +754,12 @@ public interface JdbcOperations {
|
|
|
|
|
List<Map<String, Object>> queryForList(String sql, Object[] args, int[] argTypes) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a result list.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a result list.
|
|
|
|
|
* <p>The results will be mapped to a List (one entry for each row) of
|
|
|
|
|
* Maps (one entry for each column, using the column name as the key).
|
|
|
|
|
* Each element in the list will be of the form returned by this interface's
|
|
|
|
|
* queryForMap() methods.
|
|
|
|
|
* {@code queryForMap} methods.
|
|
|
|
|
* @param sql the SQL query to execute
|
|
|
|
|
* @param args arguments to bind to the query
|
|
|
|
|
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
|
|
|
|
@ -780,8 +772,8 @@ public interface JdbcOperations {
|
|
|
|
|
List<Map<String, Object>> queryForList(String sql, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a SqlRowSet.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a SqlRowSet.
|
|
|
|
|
* <p>The results will be mapped to an SqlRowSet which holds the data in a
|
|
|
|
|
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
|
|
|
|
|
* <p>Note that, for the default implementation, JDBC RowSet support needs to
|
|
|
|
@ -803,8 +795,8 @@ public interface JdbcOperations {
|
|
|
|
|
SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a
|
|
|
|
|
* list of arguments to bind to the query, expecting a SqlRowSet.
|
|
|
|
|
* Query given SQL to create a prepared statement from SQL and a list of
|
|
|
|
|
* arguments to bind to the query, expecting a SqlRowSet.
|
|
|
|
|
* <p>The results will be mapped to an SqlRowSet which holds the data in a
|
|
|
|
|
* disconnected fashion. This wrapper will translate any SQLExceptions thrown.
|
|
|
|
|
* <p>Note that, for the default implementation, JDBC RowSet support needs to
|
|
|
|
@ -826,11 +818,12 @@ public interface JdbcOperations {
|
|
|
|
|
SqlRowSet queryForRowSet(String sql, @Nullable Object... args) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Issue a single SQL update operation (such as an insert, update or delete statement)
|
|
|
|
|
* using a PreparedStatementCreator to provide SQL and any required parameters.
|
|
|
|
|
* Issue a single SQL update operation (such as an insert, update or delete
|
|
|
|
|
* statement) using a PreparedStatementCreator to provide SQL and any
|
|
|
|
|
* required parameters.
|
|
|
|
|
* <p>A PreparedStatementCreator can either be implemented directly or
|
|
|
|
|
* configured through a PreparedStatementCreatorFactory.
|
|
|
|
|
* @param psc object that provides SQL and any necessary parameters
|
|
|
|
|
* @param psc a callback that provides SQL and any necessary parameters
|
|
|
|
|
* @return the number of rows affected
|
|
|
|
|
* @throws DataAccessException if there is any problem issuing the update
|
|
|
|
|
* @see PreparedStatementCreatorFactory
|
|
|
|
@ -843,7 +836,7 @@ public interface JdbcOperations {
|
|
|
|
|
* <p>Note that the given PreparedStatementCreator has to create a statement
|
|
|
|
|
* with activated extraction of generated keys (a JDBC 3.0 feature). This can
|
|
|
|
|
* either be done directly or through using a PreparedStatementCreatorFactory.
|
|
|
|
|
* @param psc object that provides SQL and any necessary parameters
|
|
|
|
|
* @param psc a callback that provides SQL and any necessary parameters
|
|
|
|
|
* @param generatedKeyHolder a KeyHolder that will hold the generated keys
|
|
|
|
|
* @return the number of rows affected
|
|
|
|
|
* @throws DataAccessException if there is any problem issuing the update
|
|
|
|
@ -946,14 +939,14 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Execute a JDBC data access operation, implemented as callback action
|
|
|
|
|
* working on a JDBC CallableStatement. This allows for implementing arbitrary
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed
|
|
|
|
|
* JDBC environment: that is, participating in Spring-managed transactions
|
|
|
|
|
* and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* @param csc object that can create a CallableStatement given a Connection
|
|
|
|
|
* @param action callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed JDBC
|
|
|
|
|
* environment: that is, participating in Spring-managed transactions and
|
|
|
|
|
* converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param csc a callback that creates a CallableStatement given a Connection
|
|
|
|
|
* @param action a callback that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
@ -962,23 +955,23 @@ public interface JdbcOperations {
|
|
|
|
|
/**
|
|
|
|
|
* Execute a JDBC data access operation, implemented as callback action
|
|
|
|
|
* working on a JDBC CallableStatement. This allows for implementing arbitrary
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed
|
|
|
|
|
* JDBC environment: that is, participating in Spring-managed transactions
|
|
|
|
|
* and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a
|
|
|
|
|
* domain object or a collection of domain objects.
|
|
|
|
|
* data access operations on a single Statement, within Spring's managed JDBC
|
|
|
|
|
* environment: that is, participating in Spring-managed transactions and
|
|
|
|
|
* converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.
|
|
|
|
|
* <p>The callback action can return a result object, for example a domain
|
|
|
|
|
* object or a collection of domain objects.
|
|
|
|
|
* @param callString the SQL call string to execute
|
|
|
|
|
* @param action callback object that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null}
|
|
|
|
|
* @param action a callback that specifies the action
|
|
|
|
|
* @return a result object returned by the action, or {@code null} if none
|
|
|
|
|
* @throws DataAccessException if there is any problem
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
<T> T execute(String callString, CallableStatementCallback<T> action) throws DataAccessException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute a SQL call using a CallableStatementCreator to provide SQL and any
|
|
|
|
|
* required parameters.
|
|
|
|
|
* @param csc object that provides SQL and any necessary parameters
|
|
|
|
|
* Execute a SQL call using a CallableStatementCreator to provide SQL and
|
|
|
|
|
* any required parameters.
|
|
|
|
|
* @param csc a callback that provides SQL and any necessary parameters
|
|
|
|
|
* @param declaredParameters list of declared SqlParameter objects
|
|
|
|
|
* @return a Map of extracted out parameters
|
|
|
|
|
* @throws DataAccessException if there is any problem issuing the update
|
|
|
|
|