|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.mybatis.spring.support.SqlSessionDaoSupport
public abstract class SqlSessionDaoSupport
Convenient super class for MyBatis SqlSession data access objects. In the usual case, all that a DAO needs is an SqlSessionFactory. This class also supports passing in an SqlSessionTemplate if a custom DataSource or ExceptionTranslator is needed for a specific DAO.
By default, each DAO gets its own SqlSessionTemplate which holds the SqlSessionFactory. SqlSessionTemplate is thread safe, so a single instance cannot be shared by all DAOs; there should also be a small memory savings by doing this. To support a shared template, this class has a constructor that accepts an SqlSessionTemplate. This pattern can be used in Spring configuration files as follows:
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory),
setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate),
SqlSessionTemplate,
JdbcAccessor.setExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)| Field Summary |
|---|
| Fields inherited from class org.springframework.dao.support.DaoSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
SqlSessionDaoSupport()
|
|
SqlSessionDaoSupport(SqlSessionTemplate sessionTemplate)
|
|
| Method Summary | |
|---|---|
protected void |
checkDaoConfig()
|
DataSource |
getDataSource()
Return the JDBC DataSource used by this DAO. |
org.apache.ibatis.session.SqlSessionFactory |
getSqlSessionFactory()
Return the SqlSessionFactory that this DAO uses. |
SqlSessionTemplate |
getSqlSessionTemplate()
Return the SqlSessionTemplate for this DAO, pre-initialized with the SqlSessionFactory or set explicitly. |
void |
setDataSource(DataSource dataSource)
Set the JDBC DataSource to be used by this DAO. |
void |
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sessionFactory)
Set the SqlSessionFactory to work with. |
void |
setSqlSessionTemplate(SqlSessionTemplate sessionTemplate)
Set the SqlSessionTemplate for this DAO explicitly, as an alternative to specifying a SqlSessionFactory. |
| Methods inherited from class org.springframework.dao.support.DaoSupport |
|---|
afterPropertiesSet, initDao |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SqlSessionDaoSupport()
public SqlSessionDaoSupport(SqlSessionTemplate sessionTemplate)
| Method Detail |
|---|
public final void setDataSource(DataSource dataSource)
This is a no-op if an external SqlSessionTemplate has been set.
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)public final DataSource getDataSource()
public final void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sessionFactory)
This is a no-op if an external SqlSessionTemplate has been set.
setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)public final org.apache.ibatis.session.SqlSessionFactory getSqlSessionFactory()
public final void setSqlSessionTemplate(SqlSessionTemplate sessionTemplate)
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)public final SqlSessionTemplate getSqlSessionTemplate()
protected void checkDaoConfig()
checkDaoConfig in class org.springframework.dao.support.DaoSupport
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||