|
|||||||||||
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.SqlMapTemplate
Helper class that simplifies data access via the MappedStatement 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, taking the name of a mapped statement defined in the iBATIS SqlMap config file and a callback that implements a data access action on the specified statement.
This class provides numerous convenience methods that mirror MappedStatement's executeXXX methods. See the MappedStatement javadocs for details on those methods.
NOTE: The SqlMap/MappedStatement API is the one to use with iBATIS SQL Maps 1.x. The SqlMapClient/SqlMapSession API is only available with SQL Maps 2.
execute(java.lang.String, org.springframework.orm.ibatis.SqlMapCallback)
,
setSqlMap(com.ibatis.db.sqlmap.SqlMap)
,
JdbcAccessor.setDataSource(javax.sql.DataSource)
,
JdbcAccessor.setExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)
,
MappedStatement
Constructor Summary | |
SqlMapTemplate()
Create a new SqlMapTemplate. |
|
SqlMapTemplate(javax.sql.DataSource dataSource,
com.ibatis.db.sqlmap.SqlMap sqlMap)
Create a new SqlMapTemplate. |
Method Summary | |
void |
afterPropertiesSet()
Eagerly initialize the exception translator, creating a default one for the specified DataSource if none set. |
java.lang.Object |
execute(java.lang.String statementName,
SqlMapCallback action)
Execute the given data access action on the given iBATIS mapped statement. |
java.util.List |
executeQueryForList(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.util.List |
executeQueryForList(java.lang.String statementName,
java.lang.Object parameterObject,
int skipResults,
int maxResults)
|
java.util.Map |
executeQueryForMap(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.String keyProperty)
|
java.util.Map |
executeQueryForMap(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.String keyProperty,
java.lang.String valueProperty)
|
java.lang.Object |
executeQueryForObject(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.lang.Object |
executeQueryForObject(java.lang.String statementName,
java.lang.Object parameterObject,
java.lang.Object resultObject)
|
void |
executeQueryWithRowHandler(java.lang.String statementName,
java.lang.Object parameterObject,
com.ibatis.db.sqlmap.RowHandler rowHandler)
|
int |
executeUpdate(java.lang.String statementName,
java.lang.Object parameterObject)
|
java.util.List |
executeWithListResult(java.lang.String statementName,
SqlMapCallback action)
Execute the given data access action on the given mapped statement, expecting a List result. |
java.util.Map |
executeWithMapResult(java.lang.String statementName,
SqlMapCallback action)
Execute the given data access action on the given mapped statement, expecting a Map result. |
com.ibatis.db.sqlmap.SqlMap |
getSqlMap()
Return the iBATIS Database Layer SqlMap that this template works with. |
void |
setSqlMap(com.ibatis.db.sqlmap.SqlMap sqlMap)
Set the iBATIS Database Layer SqlMap that defines the mapped statements. |
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 SqlMapTemplate()
public SqlMapTemplate(javax.sql.DataSource dataSource, com.ibatis.db.sqlmap.SqlMap sqlMap)
dataSource
- JDBC DataSource to obtain connections fromsqlMap
- iBATIS SqlMap that defines the mapped statementsMethod Detail |
public void setSqlMap(com.ibatis.db.sqlmap.SqlMap sqlMap)
public com.ibatis.db.sqlmap.SqlMap getSqlMap()
public void afterPropertiesSet()
JdbcAccessor
afterPropertiesSet
in class JdbcAccessor
public java.lang.Object execute(java.lang.String statementName, SqlMapCallback action) throws DataAccessException
statementName
- name of the statement mapped in the iBATIS SqlMap config fileaction
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.util.List executeWithListResult(java.lang.String statementName, SqlMapCallback action) throws DataAccessException
statementName
- name of the statement mapped in the iBATIS SqlMap config fileaction
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.util.Map executeWithMapResult(java.lang.String statementName, SqlMapCallback action) throws DataAccessException
statementName
- name of the statement mapped in the iBATIS SqlMap config fileaction
- callback object that specifies the data access action
DataAccessException
- in case of SQL Maps errorspublic java.lang.Object executeQueryForObject(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
executeQueryForObject
in interface SqlMapOperations
DataAccessException
public java.lang.Object executeQueryForObject(java.lang.String statementName, java.lang.Object parameterObject, java.lang.Object resultObject) throws DataAccessException
executeQueryForObject
in interface SqlMapOperations
DataAccessException
public java.util.List executeQueryForList(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
executeQueryForList
in interface SqlMapOperations
DataAccessException
public java.util.List executeQueryForList(java.lang.String statementName, java.lang.Object parameterObject, int skipResults, int maxResults) throws DataAccessException
executeQueryForList
in interface SqlMapOperations
DataAccessException
public java.util.Map executeQueryForMap(java.lang.String statementName, java.lang.Object parameterObject, java.lang.String keyProperty) throws DataAccessException
executeQueryForMap
in interface SqlMapOperations
DataAccessException
public java.util.Map executeQueryForMap(java.lang.String statementName, java.lang.Object parameterObject, java.lang.String keyProperty, java.lang.String valueProperty) throws DataAccessException
executeQueryForMap
in interface SqlMapOperations
DataAccessException
public void executeQueryWithRowHandler(java.lang.String statementName, java.lang.Object parameterObject, com.ibatis.db.sqlmap.RowHandler rowHandler) throws DataAccessException
executeQueryWithRowHandler
in interface SqlMapOperations
DataAccessException
public int executeUpdate(java.lang.String statementName, java.lang.Object parameterObject) throws DataAccessException
executeUpdate
in interface SqlMapOperations
DataAccessException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |