public class SpartaNamedParameterJdbcTemplate
extends org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
| Constructor and Description |
|---|
SpartaNamedParameterJdbcTemplate(DataSource dataSource)
Constructor using DataSource.
|
SpartaNamedParameterJdbcTemplate(org.springframework.jdbc.core.JdbcOperations jdbcOperations)
Constructor using jdbcOperations.
|
| Modifier and Type | Method and Description |
|---|---|
<T> Optional<T> |
queryForOptionalObject(String sql,
Map<String,?> paramMap,
Class<T> requiredType)
Query given SQL to create a prepared statement from SQL and a
list of arguments to bind to the query, expecting a result object.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
Map<String,?> paramMap,
org.springframework.jdbc.core.RowMapper<T> rowMapper)
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.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource,
Class<T> requiredType)
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.
|
<T> Optional<T> |
queryForOptionalObject(String sql,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource,
org.springframework.jdbc.core.RowMapper<T> rowMapper)
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.
|
batchUpdate, batchUpdate, execute, execute, execute, getCacheLimit, getJdbcOperations, getParsedSql, getPreparedStatementCreator, query, query, query, query, query, query, query, query, query, queryForList, queryForList, queryForList, queryForList, queryForMap, queryForMap, queryForObject, queryForObject, queryForObject, queryForObject, queryForRowSet, queryForRowSet, setCacheLimit, update, update, update, updatepublic SpartaNamedParameterJdbcTemplate(DataSource dataSource)
dataSource - Data Source for connecting to databasepublic SpartaNamedParameterJdbcTemplate(org.springframework.jdbc.core.JdbcOperations jdbcOperations)
jdbcOperations - to connect to databasepublic <T> Optional<T> queryForOptionalObject(String sql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource, org.springframework.jdbc.core.RowMapper<T> rowMapper) throws org.springframework.dao.DataAccessException
T - Type of the object to be returnedsql - SQL query to executeparamSource - container of arguments to bind to the queryrowMapper - object that will map one object per roworg.springframework.dao.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return exactly
one column in that roworg.springframework.dao.DataAccessException - if the query failspublic <T> Optional<T> queryForOptionalObject(String sql, Map<String,?> paramMap, org.springframework.jdbc.core.RowMapper<T> rowMapper) throws org.springframework.dao.DataAccessException
T - Type of the object to be returnedsql - SQL query to executeparamMap - 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 roworg.springframework.dao.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return exactly
one column in that roworg.springframework.dao.DataAccessException - if the query failspublic <T> Optional<T> queryForOptionalObject(String sql, org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource, Class<T> requiredType) throws org.springframework.dao.DataAccessException
T - Type of the object to be returnedsql - SQL query to executeparamSource - container of arguments to bind to the queryrequiredType - the type that the result object is expected to matchorg.springframework.dao.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return exactly
one column in that roworg.springframework.dao.DataAccessException - if the query failspublic <T> Optional<T> queryForOptionalObject(String sql, Map<String,?> paramMap, Class<T> requiredType) throws org.springframework.dao.DataAccessException
The query is expected to be a single row/single column query; the returned result will be directly mapped to the corresponding object type.
T - Type of the object to be returnedsql - SQL query to executeparamMap - map of parameters to bind to the query
(leaving it to the PreparedStatement to guess the corresponding SQL type)requiredType - the type that the result object is expected to matchorg.springframework.dao.IncorrectResultSizeDataAccessException - if the query does not return exactly one row, or does not return exactly
one column in that roworg.springframework.dao.DataAccessException - if the query failsJdbcTemplate.queryForObject(String, Class)Copyright © 2015. All rights reserved.