org.springframework.dao
exception hierarchy. Uses the same {@link org.springframework.jdbc.support.SQLExceptionTranslator}mechanism as {@link 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 {@link com.ibatis.sqlmap.client.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 {@link 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). @author Juergen Hoeller @since 24.02.2004 @see #execute @see #setSqlMapClient @see #setDataSource @see #setExceptionTranslator @see SqlMapClientFactoryBean#setDataSource @see com.ibatis.sqlmap.client.SqlMapClient#getDataSource @see com.ibatis.sqlmap.client.SqlMapExecutor
|
|
|
|