@Deprecated public class SqlMapClientTemplate extends org.springframework.jdbc.support.JdbcAccessor implements SqlMapClientOperations
SqlMapClient API, converting checked
SQLExceptions into unchecked DataAccessExceptions, following the
org.springframework.dao exception hierarchy.
Uses the same SQLExceptionTranslator
mechanism as org.springframework.jdbc.core.JdbcTemplate.
The main method of this class executes a callback that implements a
data access action. Furthermore, this class provides numerous convenience
methods that mirror SqlMapExecutor's
execution methods.
It is generally recommended to use the convenience methods on this template for plain query/insert/update/delete operations. However, for more complex operations like batch updates, a custom SqlMapClientCallback must be implemented, usually as anonymous inner class. For example:
getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
executor.update("insertSomething", "myParamValue");
executor.update("insertSomethingElse", "myOtherParamValue");
executor.executeBatch();
return null;
}
});
The template needs a SqlMapClient to work on, passed in via the "sqlMapClient"
property. A Spring context typically uses a SqlMapClientFactoryBean
to build the SqlMapClient. The template an additionally be configured with a
DataSource for fetching Connections, although this is not necessary if a
DataSource is specified for the SqlMapClient itself (typically through
SqlMapClientFactoryBean's "dataSource" property).execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>),
setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient),
JdbcAccessor.setDataSource(javax.sql.DataSource),
JdbcAccessor.setExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator),
SqlMapClientFactoryBean.setDataSource(javax.sql.DataSource),
SqlMapTransactionManager.getDataSource(),
SqlMapExecutor| Constructor and Description |
|---|
SqlMapClientTemplate()
Deprecated.
Create a new SqlMapClientTemplate.
|
SqlMapClientTemplate(DataSource dataSource,
SqlMapClient sqlMapClient)
Deprecated.
Create a new SqlMapTemplate.
|
SqlMapClientTemplate(SqlMapClient sqlMapClient)
Deprecated.
Create a new SqlMapTemplate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Deprecated.
|
int |
delete(String statementName)
Deprecated.
|
int |
delete(String statementName,
Object parameterObject)
Deprecated.
|
void |
delete(String statementName,
Object parameterObject,
int requiredRowsAffected)
Deprecated.
Convenience method provided by Spring: execute a delete operation
with an automatic check that the delete affected the given required
number of rows.
|
<T> T |
execute(SqlMapClientCallback<T> action)
Deprecated.
Execute the given data access action on a SqlMapExecutor.
|
List |
executeWithListResult(SqlMapClientCallback<List> action)
Deprecated.
as of Spring 3.0 - not really needed anymore with generic
execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>) method |
Map |
executeWithMapResult(SqlMapClientCallback<Map> action)
Deprecated.
as of Spring 3.0 - not really needed anymore with generic
execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>) method |
DataSource |
getDataSource()
Deprecated.
If no DataSource specified, use SqlMapClient's DataSource.
|
SqlMapClient |
getSqlMapClient()
Deprecated.
Return the iBATIS Database Layer SqlMapClient that this template works with.
|
Object |
insert(String statementName)
Deprecated.
|
Object |
insert(String statementName,
Object parameterObject)
Deprecated.
|
List |
queryForList(String statementName)
Deprecated.
|
List |
queryForList(String statementName,
int skipResults,
int maxResults)
Deprecated.
|
List |
queryForList(String statementName,
Object parameterObject)
Deprecated.
|
List |
queryForList(String statementName,
Object parameterObject,
int skipResults,
int maxResults)
Deprecated.
|
Map |
queryForMap(String statementName,
Object parameterObject,
String keyProperty)
Deprecated.
|
Map |
queryForMap(String statementName,
Object parameterObject,
String keyProperty,
String valueProperty)
Deprecated.
|
Object |
queryForObject(String statementName)
Deprecated.
|
Object |
queryForObject(String statementName,
Object parameterObject)
Deprecated.
|
Object |
queryForObject(String statementName,
Object parameterObject,
Object resultObject)
Deprecated.
|
void |
queryWithRowHandler(String statementName,
Object parameterObject,
RowHandler rowHandler)
Deprecated.
|
void |
queryWithRowHandler(String statementName,
RowHandler rowHandler)
Deprecated.
|
void |
setSqlMapClient(SqlMapClient sqlMapClient)
Deprecated.
Set the iBATIS Database Layer SqlMapClient that defines the mapped statements.
|
int |
update(String statementName)
Deprecated.
|
int |
update(String statementName,
Object parameterObject)
Deprecated.
|
void |
update(String statementName,
Object parameterObject,
int requiredRowsAffected)
Deprecated.
Convenience method provided by Spring: execute an update operation
with an automatic check that the update affected the given required
number of rows.
|
public SqlMapClientTemplate()
public SqlMapClientTemplate(SqlMapClient sqlMapClient)
sqlMapClient - iBATIS SqlMapClient that defines the mapped statementspublic SqlMapClientTemplate(DataSource dataSource, SqlMapClient sqlMapClient)
dataSource - JDBC DataSource to obtain connections fromsqlMapClient - iBATIS SqlMapClient that defines the mapped statementspublic void setSqlMapClient(SqlMapClient sqlMapClient)
public SqlMapClient getSqlMapClient()
public DataSource getDataSource()
getDataSource in class org.springframework.jdbc.support.JdbcAccessorSqlMapTransactionManager.getDataSource()public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanafterPropertiesSet in class org.springframework.jdbc.support.JdbcAccessorpublic <T> T execute(SqlMapClientCallback<T> action) throws org.springframework.dao.DataAccessException
action - callback object that specifies the data access actionnullorg.springframework.dao.DataAccessException - in case of SQL Maps errors@Deprecated public List executeWithListResult(SqlMapClientCallback<List> action) throws org.springframework.dao.DataAccessException
execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>) methodaction - callback object that specifies the data access actionorg.springframework.dao.DataAccessException - in case of SQL Maps errors@Deprecated public Map executeWithMapResult(SqlMapClientCallback<Map> action) throws org.springframework.dao.DataAccessException
execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>) methodaction - callback object that specifies the data access actionorg.springframework.dao.DataAccessException - in case of SQL Maps errorspublic Object queryForObject(String statementName) throws org.springframework.dao.DataAccessException
queryForObject in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForObject(String)public Object queryForObject(String statementName, Object parameterObject) throws org.springframework.dao.DataAccessException
queryForObject in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForObject(String, Object)public Object queryForObject(String statementName, Object parameterObject, Object resultObject) throws org.springframework.dao.DataAccessException
queryForObject in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForObject(String, Object, Object)public List queryForList(String statementName) throws org.springframework.dao.DataAccessException
queryForList in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForList(String)public List queryForList(String statementName, Object parameterObject) throws org.springframework.dao.DataAccessException
queryForList in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForList(String, Object)public List queryForList(String statementName, int skipResults, int maxResults) throws org.springframework.dao.DataAccessException
queryForList in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForList(String, int, int)public List queryForList(String statementName, Object parameterObject, int skipResults, int maxResults) throws org.springframework.dao.DataAccessException
queryForList in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForList(String, Object, int, int)public void queryWithRowHandler(String statementName, RowHandler rowHandler) throws org.springframework.dao.DataAccessException
queryWithRowHandler in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryWithRowHandler(String, RowHandler)public void queryWithRowHandler(String statementName, Object parameterObject, RowHandler rowHandler) throws org.springframework.dao.DataAccessException
queryWithRowHandler in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryWithRowHandler(String, Object, RowHandler)public Map queryForMap(String statementName, Object parameterObject, String keyProperty) throws org.springframework.dao.DataAccessException
queryForMap in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForMap(String, Object, String)public Map queryForMap(String statementName, Object parameterObject, String keyProperty, String valueProperty) throws org.springframework.dao.DataAccessException
queryForMap in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.queryForMap(String, Object, String, String)public Object insert(String statementName) throws org.springframework.dao.DataAccessException
insert in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.insert(String)public Object insert(String statementName, Object parameterObject) throws org.springframework.dao.DataAccessException
insert in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.insert(String, Object)public int update(String statementName) throws org.springframework.dao.DataAccessException
update in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.update(String)public int update(String statementName, Object parameterObject) throws org.springframework.dao.DataAccessException
update in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.update(String, Object)public void update(String statementName, Object parameterObject, int requiredRowsAffected) throws org.springframework.dao.DataAccessException
SqlMapClientOperationsupdate in interface SqlMapClientOperationsstatementName - the name of the mapped statementparameterObject - the parameter objectrequiredRowsAffected - the number of rows that the update is
required to affectorg.springframework.dao.DataAccessException - in case of errorspublic int delete(String statementName) throws org.springframework.dao.DataAccessException
delete in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.delete(String)public int delete(String statementName, Object parameterObject) throws org.springframework.dao.DataAccessException
delete in interface SqlMapClientOperationsorg.springframework.dao.DataAccessException - in case of errorsSqlMapExecutor.delete(String, Object)public void delete(String statementName, Object parameterObject, int requiredRowsAffected) throws org.springframework.dao.DataAccessException
SqlMapClientOperationsdelete in interface SqlMapClientOperationsstatementName - the name of the mapped statementparameterObject - the parameter objectrequiredRowsAffected - the number of rows that the delete is
required to affectorg.springframework.dao.DataAccessException - in case of errors