Class SqlSessionDaoSupport

    • Constructor Detail

      • SqlSessionDaoSupport

        public SqlSessionDaoSupport()
    • Method Detail

      • setSqlSessionFactory

        public void setSqlSessionFactory​(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
        Set MyBatis SqlSessionFactory to be used by this DAO. Will automatically create SqlSessionTemplate for the given SqlSessionFactory.
        Parameters:
        sqlSessionFactory - a factory of SqlSession
      • createSqlSessionTemplate

        protected SqlSessionTemplate createSqlSessionTemplate​(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
        Create a SqlSessionTemplate for the given SqlSessionFactory. Only invoked if populating the DAO with a SqlSessionFactory reference!

        Can be overridden in subclasses to provide a SqlSessionTemplate instance with different configuration, or a custom SqlSessionTemplate subclass.

        Parameters:
        sqlSessionFactory - the MyBatis SqlSessionFactory to create a SqlSessionTemplate for
        Returns:
        the new SqlSessionTemplate instance
        See Also:
        setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory)
      • getSqlSessionFactory

        public final org.apache.ibatis.session.SqlSessionFactory getSqlSessionFactory()
        Return the MyBatis SqlSessionFactory used by this DAO.
        Returns:
        a factory of SqlSession
      • getSqlSession

        public 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. Users should not commit/rollback/close it because it will be automatically done.
        Returns:
        Spring managed thread safe SqlSession
      • getSqlSessionTemplate

        public SqlSessionTemplate getSqlSessionTemplate()
        Return the SqlSessionTemplate for this DAO, pre-initialized with the SessionFactory or set explicitly.

        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.

        Returns:
        a template of SqlSession
      • checkDaoConfig

        protected void checkDaoConfig()
        Specified by:
        checkDaoConfig in class org.springframework.dao.support.DaoSupport