Class StatementLogSqlSession

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.ibatis.session.SqlSession

    public class StatementLogSqlSession
    extends DelegatingSqlSession

    This SqlSession wraps an actual SqlSession and logs executed sql statements. (Calls to the delete*, update*, select*, insert* methods.)

    Author:
    Daniel Meyer
    • Constructor Detail

      • StatementLogSqlSession

        public StatementLogSqlSession​(org.apache.ibatis.session.SqlSession wrappedSession)
    • Method Detail

      • delete

        public int delete​(java.lang.String statement)
        Specified by:
        delete in interface org.apache.ibatis.session.SqlSession
        Overrides:
        delete in class DelegatingSqlSession
      • delete

        public int delete​(java.lang.String statement,
                          java.lang.Object parameter)
        Specified by:
        delete in interface org.apache.ibatis.session.SqlSession
        Overrides:
        delete in class DelegatingSqlSession
      • insert

        public int insert​(java.lang.String statement)
        Specified by:
        insert in interface org.apache.ibatis.session.SqlSession
        Overrides:
        insert in class DelegatingSqlSession
      • insert

        public int insert​(java.lang.String statement,
                          java.lang.Object paremeter)
        Specified by:
        insert in interface org.apache.ibatis.session.SqlSession
        Overrides:
        insert in class DelegatingSqlSession
      • update

        public int update​(java.lang.String statement)
        Specified by:
        update in interface org.apache.ibatis.session.SqlSession
        Overrides:
        update in class DelegatingSqlSession
      • update

        public int update​(java.lang.String statement,
                          java.lang.Object parameter)
        Specified by:
        update in interface org.apache.ibatis.session.SqlSession
        Overrides:
        update in class DelegatingSqlSession
      • select

        public void select​(java.lang.String statement,
                           java.lang.Object parameter,
                           org.apache.ibatis.session.ResultHandler handler)
        Specified by:
        select in interface org.apache.ibatis.session.SqlSession
        Overrides:
        select in class DelegatingSqlSession
      • select

        public void select​(java.lang.String statement,
                           java.lang.Object parameter,
                           org.apache.ibatis.session.RowBounds rowBounds,
                           org.apache.ibatis.session.ResultHandler handler)
        Specified by:
        select in interface org.apache.ibatis.session.SqlSession
        Overrides:
        select in class DelegatingSqlSession
      • select

        public void select​(java.lang.String statement,
                           org.apache.ibatis.session.ResultHandler handler)
        Specified by:
        select in interface org.apache.ibatis.session.SqlSession
        Overrides:
        select in class DelegatingSqlSession
      • selectList

        public <E> java.util.List<E> selectList​(java.lang.String statement)
        Specified by:
        selectList in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectList in class DelegatingSqlSession
      • selectList

        public <E> java.util.List<E> selectList​(java.lang.String statement,
                                                java.lang.Object parameter)
        Specified by:
        selectList in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectList in class DelegatingSqlSession
      • selectList

        public <E> java.util.List<E> selectList​(java.lang.String statement,
                                                java.lang.Object parameter,
                                                org.apache.ibatis.session.RowBounds rowBounds)
        Specified by:
        selectList in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectList in class DelegatingSqlSession
      • selectMap

        public <K,​V> java.util.Map<K,​V> selectMap​(java.lang.String statement,
                                                              java.lang.Object parameter,
                                                              java.lang.String mapKey)
        Specified by:
        selectMap in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectMap in class DelegatingSqlSession
      • selectMap

        public <K,​V> java.util.Map<K,​V> selectMap​(java.lang.String statement,
                                                              java.lang.Object parameter,
                                                              java.lang.String mapKey,
                                                              org.apache.ibatis.session.RowBounds rowBounds)
        Specified by:
        selectMap in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectMap in class DelegatingSqlSession
      • selectMap

        public <K,​V> java.util.Map<K,​V> selectMap​(java.lang.String statement,
                                                              java.lang.String mapKey)
        Specified by:
        selectMap in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectMap in class DelegatingSqlSession
      • selectOne

        public <T> T selectOne​(java.lang.String statement)
        Specified by:
        selectOne in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectOne in class DelegatingSqlSession
      • selectOne

        public <T> T selectOne​(java.lang.String statement,
                               java.lang.Object parameter)
        Specified by:
        selectOne in interface org.apache.ibatis.session.SqlSession
        Overrides:
        selectOne in class DelegatingSqlSession
      • stopLogging

        public static java.util.List<StatementLogSqlSession.SqlStatementLog> stopLogging()
        stops logging statement executed by the current thread and returns the list of logged statements.
        Returns:
        the List of logged sql statements
      • startLogging

        public static void startLogging()
        starts logging any statements executed by the calling thread.