|
||||||||||
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
public class SqlMapTemplate
Helper class that simplifies data access via the MappedStatement API of iBATIS
SQL Maps, and converts checked SQLExceptions into unchecked DataAccessExceptions,
following 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
Field Summary |
---|
Fields inherited from class org.springframework.jdbc.support.JdbcAccessor |
---|
logger |
Constructor Summary | |
---|---|
SqlMapTemplate()
Create a new SqlMapTemplate. |
|
SqlMapTemplate(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. |
Object |
execute(String statementName,
SqlMapCallback action)
Execute the given data access action on the given iBATIS mapped statement. |
List |
executeQueryForList(String statementName,
Object parameterObject)
|
List |
executeQueryForList(String statementName,
Object parameterObject,
int skipResults,
int maxResults)
|
Map |
executeQueryForMap(String statementName,
Object parameterObject,
String keyProperty)
|
Map |
executeQueryForMap(String statementName,
Object parameterObject,
String keyProperty,
String valueProperty)
|
Object |
executeQueryForObject(String statementName,
Object parameterObject)
|
Object |
executeQueryForObject(String statementName,
Object parameterObject,
Object resultObject)
|
void |
executeQueryWithRowHandler(String statementName,
Object parameterObject,
com.ibatis.db.sqlmap.RowHandler rowHandler)
|
int |
executeUpdate(String statementName,
Object parameterObject)
|
List |
executeWithListResult(String statementName,
SqlMapCallback action)
Execute the given data access action on the given mapped statement, expecting a List result. |
Map |
executeWithMapResult(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, 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 |
---|
public SqlMapTemplate()
public SqlMapTemplate(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 interface InitializingBean
afterPropertiesSet
in class JdbcAccessor
public Object execute(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
null
DataAccessException
- in case of SQL Maps errorspublic List executeWithListResult(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 Map executeWithMapResult(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 Object executeQueryForObject(String statementName, Object parameterObject) throws DataAccessException
executeQueryForObject
in interface SqlMapOperations
DataAccessException
public Object executeQueryForObject(String statementName, Object parameterObject, Object resultObject) throws DataAccessException
executeQueryForObject
in interface SqlMapOperations
DataAccessException
public List executeQueryForList(String statementName, Object parameterObject) throws DataAccessException
executeQueryForList
in interface SqlMapOperations
DataAccessException
public List executeQueryForList(String statementName, Object parameterObject, int skipResults, int maxResults) throws DataAccessException
executeQueryForList
in interface SqlMapOperations
DataAccessException
public Map executeQueryForMap(String statementName, Object parameterObject, String keyProperty) throws DataAccessException
executeQueryForMap
in interface SqlMapOperations
DataAccessException
public Map executeQueryForMap(String statementName, Object parameterObject, String keyProperty, String valueProperty) throws DataAccessException
executeQueryForMap
in interface SqlMapOperations
DataAccessException
public void executeQueryWithRowHandler(String statementName, Object parameterObject, com.ibatis.db.sqlmap.RowHandler rowHandler) throws DataAccessException
executeQueryWithRowHandler
in interface SqlMapOperations
DataAccessException
public int executeUpdate(String statementName, 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 |