|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mybatis.spring.transaction.SpringManagedTransaction
public class SpringManagedTransaction
MyBatis has two TransactionManagers out of the box: The JdbcTransaction and the
ManagedTransaction. When MyBatis runs under a Spring transaction none of them
will work fine because JdbcTransaction will commit/rollback/close and it should not
and ManagedTransaction will close the connection and it should not.
SpringManagedTransaction looks if the current connection is being managed by Spring.
In that case it will no-op all commit/rollback/close calls assuming that the Spring
transaction manager will do the job. Otherwise it will behave almost like JdbcTransaction.
| Constructor Summary | |
|---|---|
SpringManagedTransaction(Connection connection,
DataSource dataSource)
Constructor that discovers if this Transaction should manage connection or let it to Spring. |
|
| Method Summary | |
|---|---|
void |
close()
|
void |
commit()
|
Connection |
getConnection()
|
void |
rollback()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SpringManagedTransaction(Connection connection,
DataSource dataSource)
Transaction should manage connection or let it to Spring. It gets both
the Connection and the DataSource it was built from and asks Spring if they are bundled to the
current transaction.
connection - JDBC connection to managedataSource - The DataSource that was configured in current SqlSessionFactory| Method Detail |
|---|
public Connection getConnection()
getConnection in interface org.apache.ibatis.transaction.Transaction
public void commit()
throws SQLException
commit in interface org.apache.ibatis.transaction.TransactionSQLException
public void rollback()
throws SQLException
rollback in interface org.apache.ibatis.transaction.TransactionSQLException
public void close()
throws SQLException
close in interface org.apache.ibatis.transaction.TransactionSQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||