org.mybatis.spring.transaction
Class SpringManagedTransaction
java.lang.Object
org.mybatis.spring.transaction.SpringManagedTransaction
- All Implemented Interfaces:
- org.apache.ibatis.transaction.Transaction
public class SpringManagedTransaction
- extends Object
- implements org.apache.ibatis.transaction.Transaction
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 well because JdbcTransaction
would commit/rollback/close and it should not.
And ManagedTransaction
would close the connection and it should not.
SpringManagedTransaction
looks if the current connection is been managed by Spring. In that case
it will not commit/rollback/close. Otherwise it will behave like JdbcTransaction
.
- Version:
- $Id: SpringManagedTransaction.java 3266 2010-11-22 06:56:51Z simone.tripodi $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpringManagedTransaction
public SpringManagedTransaction(Connection connection)
getConnection
public Connection getConnection()
-
- Specified by:
getConnection
in interface org.apache.ibatis.transaction.Transaction
commit
public void commit()
throws SQLException
-
- Specified by:
commit
in interface org.apache.ibatis.transaction.Transaction
- Throws:
SQLException
rollback
public void rollback()
throws SQLException
-
- Specified by:
rollback
in interface org.apache.ibatis.transaction.Transaction
- Throws:
SQLException
close
public void close()
throws SQLException
-
- Specified by:
close
in interface org.apache.ibatis.transaction.Transaction
- Throws:
SQLException
Copyright © 2010 MyBatis.org. All Rights Reserved.