public abstract class SqlSessionDaoSupport
extends org.springframework.dao.support.DaoSupport
This class needs a SqlSessionTemplate or a SqlSessionFactory. If both are set the SqlSessionFactory will be ignored.
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
,
setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate)
,
SqlSessionTemplate
Constructor and Description |
---|
SqlSessionDaoSupport() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkDaoConfig() |
protected SqlSessionTemplate |
createSqlSessionTemplate(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
Create a SqlSessionTemplate for the given SqlSessionFactory.
|
org.apache.ibatis.session.SqlSession |
getSqlSession()
Users should use this method to get a SqlSession to call its statement methods
This is SqlSession is managed by spring.
|
org.apache.ibatis.session.SqlSessionFactory |
getSqlSessionFactory()
Return the MyBatis SqlSessionFactory used by this DAO.
|
SqlSessionTemplate |
getSqlSessionTemplate()
Return the SqlSessionTemplate for this DAO,
pre-initialized with the SessionFactory or set explicitly.
|
void |
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
Set MyBatis SqlSessionFactory to be used by this DAO.
|
void |
setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
Set the SqlSessionTemplate for this DAO explicitly,
as an alternative to specifying a SqlSessionFactory.
|
public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
sqlSessionFactory
- a factory of SqlSessionprotected SqlSessionTemplate createSqlSessionTemplate(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
Can be overridden in subclasses to provide a SqlSessionTemplate instance with different configuration, or a custom SqlSessionTemplate subclass.
sqlSessionFactory
- the MyBatis SqlSessionFactory to create a SqlSessionTemplate forsetSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
public final org.apache.ibatis.session.SqlSessionFactory getSqlSessionFactory()
public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
sqlSessionTemplate
- a template of SqlSessionsetSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
public org.apache.ibatis.session.SqlSession getSqlSession()
public SqlSessionTemplate getSqlSessionTemplate()
Note: The returned SqlSessionTemplate is a shared instance.
You may introspect its configuration, but not modify the configuration
(other than from within an DaoSupport.initDao()
implementation).
Consider creating a custom SqlSessionTemplate instance via
new SqlSessionTemplate(getSqlSessionFactory())
, in which case
you're allowed to customize the settings on the resulting instance.
protected void checkDaoConfig()
checkDaoConfig
in class org.springframework.dao.support.DaoSupport
Copyright © 2010–2019 MyBatis.org. All rights reserved.