|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.support.JdbcAccessor org.springframework.orm.ibatis.SqlMapClientTemplate
Helper class that simplifies data access via the SqlMapClient API of the iBATIS Database Layer, and converts checked SQLExceptions into unchecked DataAccessExceptions, compatible to the org.springframework.dao exception hierarchy. Uses the same SQLExceptionTranslator mechanism as JdbcTemplate.
The main method is execute, a callback that implements a data access action. This class provides numerous convenience methods that mirror SqlMapSession's execution methods. See the SqlMapClient javadocs for details on those methods.
NOTE: The SqlMapClient/SqlMapSession API is the API of iBATIS SQL Maps 2. With SQL Maps 1.x, the SqlMap/MappedStatement API has to be used.
execute(org.springframework.orm.ibatis.SqlMapClientCallback)
,
setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient)
,
JdbcAccessor.setDataSource(javax.sql.DataSource)
,
JdbcAccessor.setExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)
,
SqlMapSession
Constructor Summary | |
SqlMapClientTemplate()
Create a new SqlMapClientTemplate. |
|
SqlMapClientTemplate(javax.sql.DataSource dataSource,
com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
Create a new SqlMapTemplate. |
Method Summary | |
void |
afterPropertiesSet()
Eagerly initialize the exception translator, creating a default one for the specified DataSource if none set. |
int |
delete(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.lang.Object |
execute(SqlMapClientCallback action)
Execute the given data access action on an SqlMapSession. |
java.util.List |
executeWithListResult(SqlMapClientCallback action)
Execute the given data access action on an SqlMapSession, expecting a List result. |
java.util.Map |
executeWithMapResult(SqlMapClientCallback action)
Execute the given data access action on an SqlMapSession, expecting a Map result. |
com.ibatis.sqlmap.client.SqlMapClient |
getSqlMapClient()
Return the iBATIS Database Layer SqlMapClient that this template works with. |
java.lang.Object |
insert(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.util.List |
queryForList(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.util.List |
queryForList(java.lang.String statementName,
java.lang.Object parameterObject,
int skipResults,
int maxResults)
|
java.util.List |
queryForList(java.lang.String statementName,
java.lang.Object parameterObject,
com.ibatis.sqlmap.client.event.RowHandler rowHandler)
|
java.util.Map |
queryForMap(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.String keyProperty)
|
java.util.Map |
queryForMap(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.String keyProperty,
java.lang.String valueProperty)
|
java.lang.Object |
queryForObject(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.lang.Object |
queryForObject(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.Object resultObject)
|
void |
setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
Set the iBATIS Database Layer SqlMapClient that defines the mapped statements. |
int |
update(java.lang.String statementName,
java.lang.Object parameterObject)
|
Methods inherited from class org.springframework.jdbc.support.JdbcAccessor |
getDataSource, getExceptionTranslator, setDataSource, setExceptionTranslator |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SqlMapClientTemplate()
public SqlMapClientTemplate(javax.sql.DataSource dataSource, com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
dataSource
- JDBC DataSource to obtain connections fromsqlMapClient
- iBATIS SqlMapClient that defines the mapped statementsMethod Detail |
public void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
public com.ibatis.sqlmap.client.SqlMapClient getSqlMapClient()
public void afterPropertiesSet()
JdbcAccessor
afterPropertiesSet
in class JdbcAccessor
public java.lang.Object execute(SqlMapClientCallback action) throws DataAccessException
action
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.util.List executeWithListResult(SqlMapClientCallback action) throws DataAccessException
action
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.util.Map executeWithMapResult(SqlMapClientCallback action) throws DataAccessException
action
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.lang.Object queryForObject(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
queryForObject
in interface SqlMapClientOperations
DataAccessException
public java.lang.Object queryForObject(java.lang.String statementName, java.lang.Object parameterObject, java.lang.Object resultObject) throws DataAccessException
queryForObject
in interface SqlMapClientOperations
DataAccessException
public java.util.List queryForList(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
queryForList
in interface SqlMapClientOperations
DataAccessException
public java.util.List queryForList(java.lang.String statementName, java.lang.Object parameterObject, int skipResults, int maxResults) throws DataAccessException
queryForList
in interface SqlMapClientOperations
DataAccessException
public java.util.List queryForList(java.lang.String statementName, java.lang.Object parameterObject, com.ibatis.sqlmap.client.event.RowHandler rowHandler) throws DataAccessException
queryForList
in interface SqlMapClientOperations
DataAccessException
public java.util.Map queryForMap(java.lang.String statementName, java.lang.Object parameterObject, java.lang.String keyProperty) throws DataAccessException
queryForMap
in interface SqlMapClientOperations
DataAccessException
public java.util.Map queryForMap(java.lang.String statementName, java.lang.Object parameterObject, java.lang.String keyProperty, java.lang.String valueProperty) throws DataAccessException
queryForMap
in interface SqlMapClientOperations
DataAccessException
public java.lang.Object insert(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
insert
in interface SqlMapClientOperations
DataAccessException
public int update(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
update
in interface SqlMapClientOperations
DataAccessException
public int delete(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
delete
in interface SqlMapClientOperations
DataAccessException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |