org.springframework.orm.ibatis

## Class SqlMapClientTemplate

- java.lang.Object
- - org.springframework.jdbc.support.JdbcAccessor
  - - org.springframework.orm.ibatis.SqlMapClientTemplate

- All Implemented Interfaces:
    InitializingBean, SqlMapClientOperations

  Deprecated.
  as of Spring 3.2, in favor of the native Spring support in the Mybatis follow-up project (http://code.google.com/p/mybatis/)

      @Deprecated
      public class SqlMapClientTemplate
      extends JdbcAccessor
      implements SqlMapClientOperations

  Helper class that simplifies data access via the iBATIS `SqlMapClient` API, converting checked SQLExceptions into unchecked DataAccessExceptions, following the `org.springframework.dao` exception hierarchy. Uses the same `SQLExceptionTranslator` mechanism as `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).
  Since:
    24.02.2004
  Author:
    Juergen Hoeller
  See Also:
    `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`

- - ### Field Summary

    - ### Fields inherited from class org.springframework.jdbc.support.JdbcAccessor

      `logger`

  - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Deprecated. Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.
    `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.

    - ### Methods inherited from class org.springframework.jdbc.support.JdbcAccessor

      `getExceptionTranslator, isLazyInit, setDatabaseProductName, setDataSource, setExceptionTranslator, setLazyInit`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SqlMapClientTemplate

          public SqlMapClientTemplate()

      Deprecated.
      Create a new SqlMapClientTemplate.

    - #### SqlMapClientTemplate

          public SqlMapClientTemplate(SqlMapClient sqlMapClient)

      Deprecated.
      Create a new SqlMapTemplate.
      Parameters:
        `sqlMapClient` - iBATIS SqlMapClient that defines the mapped statements

    - #### SqlMapClientTemplate

          public SqlMapClientTemplate(DataSource dataSource,
                              SqlMapClient sqlMapClient)

      Deprecated.
      Create a new SqlMapTemplate.
      Parameters:
        `dataSource` - JDBC DataSource to obtain connections from
        `sqlMapClient` - iBATIS SqlMapClient that defines the mapped statements

  - ### Method Detail

    - #### setSqlMapClient

          public void setSqlMapClient(SqlMapClient sqlMapClient)

      Deprecated.
      Set the iBATIS Database Layer SqlMapClient that defines the mapped statements.

    - #### getSqlMapClient

          public SqlMapClient getSqlMapClient()

      Deprecated.
      Return the iBATIS Database Layer SqlMapClient that this template works with.

    - #### getDataSource

          public DataSource getDataSource()

      Deprecated.
      If no DataSource specified, use SqlMapClient's DataSource.
      Overrides:
        `getDataSource` in class `JdbcAccessor`
      See Also:
        `SqlMapTransactionManager.getDataSource()`

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Deprecated.
      Description copied from class: `JdbcAccessor`
      Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.
      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Overrides:
        `afterPropertiesSet` in class `JdbcAccessor`

    - #### execute

          public <T> T execute(SqlMapClientCallback<T> action)
                    throws DataAccessException

      Deprecated.
      Execute the given data access action on a SqlMapExecutor.
      Parameters:
        `action` - callback object that specifies the data access action
      Returns:
        a result object returned by the action, or `null`
      Throws:
        `DataAccessException` - in case of SQL Maps errors

    - #### executeWithListResult

          @Deprecated
          public List executeWithListResult(SqlMapClientCallback<List> action)
                                     throws DataAccessException

      Deprecated. as of Spring 3.0 - not really needed anymore with generic `execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>)` method
      Execute the given data access action on a SqlMapExecutor, expecting a List result.
      Parameters:
        `action` - callback object that specifies the data access action
      Returns:
        the List result
      Throws:
        `DataAccessException` - in case of SQL Maps errors

    - #### executeWithMapResult

          @Deprecated
          public Map executeWithMapResult(SqlMapClientCallback<Map> action)
                                   throws DataAccessException

      Deprecated. as of Spring 3.0 - not really needed anymore with generic `execute(org.springframework.orm.ibatis.SqlMapClientCallback<T>)` method
      Execute the given data access action on a SqlMapExecutor, expecting a Map result.
      Parameters:
        `action` - callback object that specifies the data access action
      Returns:
        the Map result
      Throws:
        `DataAccessException` - in case of SQL Maps errors

    - #### queryForObject

          public Object queryForObject(String statementName)
                                throws DataAccessException

      Deprecated.
      Specified by:
        `queryForObject` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForObject(String)`

    - #### queryForObject

          public Object queryForObject(String statementName,
                              Object parameterObject)
                                throws DataAccessException

      Deprecated.
      Specified by:
        `queryForObject` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForObject(String, Object)`

    - #### queryForObject

          public Object queryForObject(String statementName,
                              Object parameterObject,
                              Object resultObject)
                                throws DataAccessException

      Deprecated.
      Specified by:
        `queryForObject` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForObject(String, Object, Object)`

    - #### queryForList

          public List queryForList(String statementName)
                            throws DataAccessException

      Deprecated.
      Specified by:
        `queryForList` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForList(String)`

    - #### queryForList

          public List queryForList(String statementName,
                          Object parameterObject)
                            throws DataAccessException

      Deprecated.
      Specified by:
        `queryForList` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForList(String, Object)`

    - #### queryForList

          public List queryForList(String statementName,
                          int skipResults,
                          int maxResults)
                            throws DataAccessException

      Deprecated.
      Specified by:
        `queryForList` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForList(String, int, int)`

    - #### queryForList

          public List queryForList(String statementName,
                          Object parameterObject,
                          int skipResults,
                          int maxResults)
                            throws DataAccessException

      Deprecated.
      Specified by:
        `queryForList` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForList(String, Object, int, int)`

    - #### queryWithRowHandler

          public void queryWithRowHandler(String statementName,
                                 RowHandler rowHandler)
                                   throws DataAccessException

      Deprecated.
      Specified by:
        `queryWithRowHandler` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryWithRowHandler(String, RowHandler)`

    - #### queryWithRowHandler

          public void queryWithRowHandler(String statementName,
                                 Object parameterObject,
                                 RowHandler rowHandler)
                                   throws DataAccessException

      Deprecated.
      Specified by:
        `queryWithRowHandler` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryWithRowHandler(String, Object, RowHandler)`

    - #### queryForMap

          public Map queryForMap(String statementName,
                        Object parameterObject,
                        String keyProperty)
                          throws DataAccessException

      Deprecated.
      Specified by:
        `queryForMap` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForMap(String, Object, String)`

    - #### queryForMap

          public Map queryForMap(String statementName,
                        Object parameterObject,
                        String keyProperty,
                        String valueProperty)
                          throws DataAccessException

      Deprecated.
      Specified by:
        `queryForMap` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.queryForMap(String, Object, String, String)`

    - #### insert

          public Object insert(String statementName)
                        throws DataAccessException

      Deprecated.
      Specified by:
        `insert` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.insert(String)`

    - #### insert

          public Object insert(String statementName,
                      Object parameterObject)
                        throws DataAccessException

      Deprecated.
      Specified by:
        `insert` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.insert(String, Object)`

    - #### update

          public int update(String statementName)
                     throws DataAccessException

      Deprecated.
      Specified by:
        `update` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.update(String)`

    - #### update

          public int update(String statementName,
                   Object parameterObject)
                     throws DataAccessException

      Deprecated.
      Specified by:
        `update` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.update(String, Object)`

    - #### update

          public void update(String statementName,
                    Object parameterObject,
                    int requiredRowsAffected)
                      throws DataAccessException

      Deprecated.
      Description copied from interface: `SqlMapClientOperations`
      Convenience method provided by Spring: execute an update operation with an automatic check that the update affected the given required number of rows.
      Specified by:
        `update` in interface `SqlMapClientOperations`
      Parameters:
        `statementName` - the name of the mapped statement
        `parameterObject` - the parameter object
        `requiredRowsAffected` - the number of rows that the update is required to affect
      Throws:
        `DataAccessException` - in case of errors

    - #### delete

          public int delete(String statementName)
                     throws DataAccessException

      Deprecated.
      Specified by:
        `delete` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.delete(String)`

    - #### delete

          public int delete(String statementName,
                   Object parameterObject)
                     throws DataAccessException

      Deprecated.
      Specified by:
        `delete` in interface `SqlMapClientOperations`
      Throws:
        `DataAccessException` - in case of errors
      See Also:
        `SqlMapExecutor.delete(String, Object)`

    - #### delete

          public void delete(String statementName,
                    Object parameterObject,
                    int requiredRowsAffected)
                      throws DataAccessException

      Deprecated.
      Description copied from interface: `SqlMapClientOperations`
      Convenience method provided by Spring: execute a delete operation with an automatic check that the delete affected the given required number of rows.
      Specified by:
        `delete` in interface `SqlMapClientOperations`
      Parameters:
        `statementName` - the name of the mapped statement
        `parameterObject` - the parameter object
        `requiredRowsAffected` - the number of rows that the delete is required to affect
      Throws:
        `DataAccessException` - in case of errors