org.mybatis.spring.transaction
Class SpringManagedTransaction

java.lang.Object
  extended by 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 JdbcTransactionManager and the ExternalTransactionManager. When MyBatis runs under a Spring transaction none of them will work well because JDBCTransactionManager would commit/rollback/close and it should not. And ExternalTransactionManager 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 JdbcTransactionManager

Version:
$Id: SpringManagedTransaction.java 2892 2010-10-25 07:12:06Z eduardo.macarron $

Constructor Summary
SpringManagedTransaction(Connection connection)
           
 
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

SpringManagedTransaction

public SpringManagedTransaction(Connection connection)
Method Detail

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.