Package com.aspectran.mybatis
Class SqlSessionTxAdvice
java.lang.Object
com.aspectran.mybatis.SqlSessionTxAdvice
Advice for SqlSession Transactions.
- Since:
- 2015. 04. 03.
- Author:
- Juho Jeong
-
Constructor Summary
ConstructorsConstructorDescriptionSqlSessionTxAdvice
(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.ExecutorType
org.apache.ibatis.session.SqlSession
Returns an open SqlSession.boolean
Returns whether the session was logically closed in user code, not by the framework.boolean
void
open()
Opens a new SqlSession and store its instance inside.void
open
(boolean autoCommit) void
void
void
open
(org.apache.ibatis.session.ExecutorType 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
(String executorType) Sets the mode for using PreparedStatements effectively.void
setExecutorType
(org.apache.ibatis.session.ExecutorType executorType) Sets the mode for using PreparedStatements effectively.
-
Constructor Details
-
SqlSessionTxAdvice
public SqlSessionTxAdvice(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
-
-
Method Details
-
isAutoCommit
public boolean isAutoCommit() -
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
-
getExecutorType
public org.apache.ibatis.session.ExecutorType getExecutorType() -
setExecutorType
public void setExecutorType(org.apache.ibatis.session.ExecutorType executorType) Sets the mode for using PreparedStatements effectively.- Parameters:
executorType
- executor types include SIMPLE, REUSE, and BATCH
-
setExecutorType
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
-
open
public void open(org.apache.ibatis.session.ExecutorType executorType, boolean autoCommit) -
open
-
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, callcommit(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, callrollback(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
-