Class SqlSessionTxAdvice


  • public class SqlSessionTxAdvice
    extends java.lang.Object
    Advice for SqlSession Transactions.
    Since:
    2015. 04. 03.
    Author:
    Juho Jeong
    • Constructor Summary

      Constructors 
      Constructor Description
      SqlSessionTxAdvice​(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the session.
      void close​(boolean arbitrarily)
      Closes the session.
      void commit()
      Flushes batch statements and commits database connection.
      void commit​(boolean force)
      Flushes batch statements and commits database connection.
      org.apache.ibatis.session.SqlSession getSqlSession()
      Returns an open SqlSession.
      boolean isArbitrarilyClosed()
      Returns whether the session was logically closed in user code, not by the framework.
      void open()
      Opens a new SqlSession and store its instance inside.
      void open​(boolean autoCommit)  
      void open​(java.lang.String executorType)  
      void open​(java.lang.String executorType, boolean autoCommit)  
      void rollback()
      Discards pending batch statements and rolls database connection back.
      void rollback​(boolean force)
      Discards pending batch statements and rolls database connection back.
      void setAutoCommit​(boolean autoCommit)
      Specifies whether to auto-commit.
      void setExecutorType​(java.lang.String executorType)
      Sets the mode for using PreparedStatements effectively.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SqlSessionTxAdvice

        public SqlSessionTxAdvice​(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
    • Method Detail

      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
        Specifies whether to auto-commit.
        Parameters:
        autoCommit - true to automatically commit each time updates/deletes/inserts is called, false to commit manually
      • setExecutorType

        public void setExecutorType​(java.lang.String executorType)
        Sets the mode for using PreparedStatements effectively.
        Parameters:
        executorType - executor types include SIMPLE, REUSE, and BATCH, and can be specified as a string value
      • getSqlSession

        public org.apache.ibatis.session.SqlSession getSqlSession()
        Returns an open SqlSession. If no SqlSession is open then return null.
        Returns:
        a SqlSession instance
      • open

        public void open()
        Opens a new SqlSession and store its instance inside. Therefore, whenever there is a request for a SqlSessionTxAdvice bean, a new bean instance of the object must be created.
      • open

        public void open​(boolean autoCommit)
      • open

        public void open​(java.lang.String executorType)
      • open

        public void open​(java.lang.String executorType,
                         boolean autoCommit)
      • commit

        public void commit()
        Flushes batch statements and commits database connection. Note that database connection will not be committed if no updates/deletes/inserts were called. To force the commit, call commit(boolean).
      • commit

        public void commit​(boolean force)
        Flushes batch statements and commits database connection.
        Parameters:
        force - forces connection commit
      • rollback

        public void rollback()
        Discards pending batch statements and rolls database connection back. Note that database connection will not be rolled back if no updates/deletes/inserts were called. To force the rollback, call rollback(boolean).
      • rollback

        public void rollback​(boolean force)
        Discards pending batch statements and rolls database connection back. Note that database connection will not be rolled back if no updates/deletes/inserts were called.
        Parameters:
        force - forces connection rollback
      • close

        public void close()
        Closes the session.
      • close

        public void close​(boolean arbitrarily)
        Closes the session.
        Parameters:
        arbitrarily - true if the session is arbitrarily closed by user code, false otherwise
      • isArbitrarilyClosed

        public boolean isArbitrarilyClosed()
        Returns whether the session was logically closed in user code, not by the framework.
        Returns:
        true if the session was closed by user code, false otherwise