This class delegates to a wrapped JdbcTemplate
once the substitution from named parameters to JDBC style '?' placeholders is
done at execution time. It also allows for expanding a java.
of values to the appropriate number of placeholders.
An instance of this template class is thread-safe once configured.
The underlying org. is
exposed to allow for convenient access to the traditional
org. methods.
NOTE: As of 6.1, there is a unified JDBC access facade available in
the form of org..
JdbcClient provides a fluent API style for common JDBC queries/updates
with flexible use of indexed or named parameters. It delegates to a
JdbcTemplate/NamedParameterJdbcTemplate for actual execution.
NamedParameterJdbcOperations, SqlParameterSource, ResultSetExtractor, RowCallbackHandler, RowMapper, org.springframework.jdbc.core.JdbcTemplate
| Modifier and Type | Field and Description |
|---|---|
| private final JdbcOperations | classicJdbcTemplate
The JdbcTemplate we are wrapping. |
| public static final int | DEFAULT_CACHE_LIMIT
Default maximum number of entries for this template's SQL cache: 256. |
| private volatile ConcurrentLruCache | parsedSqlCache
Cache of original SQL String to ParsedSql representation. |
| Access | Constructor and Description |
|---|---|
| public | NamedParameterJdbcTemplate(DataSource
the JDBC DataSource to access dataSource)Create a new NamedParameterJdbcTemplate for the given |
| public | NamedParameterJdbcTemplate(JdbcOperations
the classic Spring JdbcTemplate to wrap classicJdbcTemplate)Create a new NamedParameterJdbcTemplate for the given classic
Spring |
| Modifier and Type | Method and Description |
|---|---|
| public int[] | batchUpdate(String
the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs)SqlParameterSource containing the batch of
arguments for the queryImplements org. |
| public int[] | batchUpdate(String
the SQL statement to execute sql, Map<String, ?>[] the array of Maps containing the batch of arguments for the query batchValues)Implements org. |
| public int[] | batchUpdate(String
the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs, KeyHolder SqlParameterSource containing the batch of
arguments for the querya generatedKeyHolder)KeyHolder that will hold the generated keysImplements org. |
| public int[] | batchUpdate(String
the SQL statement to execute sql, SqlParameterSource[] the array of batchArgs, KeyHolder SqlParameterSource containing the batch of
arguments for the querya generatedKeyHolder, String[] KeyHolder that will hold the generated keysnames of the columns that will have keys generated for them keyColumnNames)Implements org. |
| public <T> T | execute(String
the SQL to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, PreparedStatementCallback<T> callback object that specifies the action action)Implements org. |
| public <T> T | execute(String
the SQL to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, PreparedStatementCallback<T> callback object that specifies the action action)Implements org. |
| public <T> T | execute(String
the SQL to execute sql, PreparedStatementCallback<T> callback object that specifies the action action)Implements org. |
| public int | |
| public JdbcOperations | getJdbcOperations()
Implements org. |
| public JdbcTemplate | getJdbcTemplate()
Expose the classic Spring |
| protected ParsedSql | Returns: a representation of the parsed SQL statementthe original SQL statement sql)Obtain a parsed representation of the given SQL statement. |
| protected PreparedStatementCreator | Returns: the correspondingPreparedStatementCreatorthe SQL statement to execute sql, SqlParameterSource container of arguments to bind paramSource)Build a |
| protected PreparedStatementCreator | Returns: the correspondingPreparedStatementCreatorthe SQL statement to execute sql, SqlParameterSource container of arguments to bind paramSource, Consumer<PreparedStatementCreatorFactory> callback for setting further properties on the
customizer)PreparedStatementCreatorFactory in use, applied before the
actual newPreparedStatementCreator callBuild a |
| protected PreparedStatementCreatorFactory | Returns: the correspondingPreparedStatementCreatorFactoryparsed representation of the given SQL statement parsedSql, SqlParameterSource container of arguments to bind paramSource)Build a |
| public <T> T | query(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, ResultSetExtractor<T> object that will extract results rse)Implements org. |
| public <T> T | query(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, ResultSetExtractor<T> object that will extract results rse)Implements org. |
| public <T> T | query(String
the SQL query to execute sql, ResultSetExtractor<T> object that will extract results rse)Implements org. |
| public void | query(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowCallbackHandler object that will extract results, one row at a time rch)Implements org. |
| public void | query(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowCallbackHandler object that will extract results, one row at a time rch)Implements org. |
| public void | query(String
the SQL query to execute sql, RowCallbackHandler object that will extract results, one row at a time rch)Implements org. |
| public <T> List | query(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> List | query(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> List | query(String
the SQL query to execute sql, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> List | queryForList(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, Class<T> the required type of element in the result list
(for example, elementType)Integer.class)Implements org. |
| public <T> List | queryForList(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, Class<T> the required type of element in the result list
(for example, elementType)Integer.class)Implements org. |
| public List | queryForList(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Implements org. |
| public List | queryForList(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Implements org. |
| public Map | queryForMap(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Implements org. |
| public Map | queryForMap(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Implements org. |
| public <T> T | queryForObject(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> T | queryForObject(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> T | queryForObject(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, Class<T> the type that the result object is expected to match requiredType)Implements org. |
| public <T> T | queryForObject(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, Class<T> the type that the result object is expected to match requiredType)Implements org. |
| public SqlRowSet | queryForRowSet(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource)Implements org. |
| public SqlRowSet | queryForRowSet(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Implements org. |
| public <T> Stream | queryForStream(String
the SQL query to execute sql, SqlParameterSource container of arguments to bind to the query paramSource, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public <T> Stream | queryForStream(String
the SQL query to execute sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap, RowMapper<T> object that will map one object per row rowMapper)Implements org. |
| public void | |
| public int | update(String
the SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource)Implements org. |
| public int | update(String
the SQL containing named parameters sql, Map<String, ?> map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type) paramMap)Implements org. |
| public int | update(String
the SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource, KeyHolder a generatedKeyHolder)KeyHolder that will hold the generated keysImplements org. |
| public int | update(String
the SQL containing named parameters sql, SqlParameterSource container of arguments and SQL types to bind to the query paramSource, KeyHolder a generatedKeyHolder, String[] KeyHolder that will hold the generated keysnames of the columns that will have keys generated for them keyColumnNames)Implements org. |