org.apache.ibatis.transaction.jdbc
Class JdbcTransaction

java.lang.Object
  extended by org.apache.ibatis.transaction.jdbc.JdbcTransaction
All Implemented Interfaces:
Transaction

public class JdbcTransaction
extends Object
implements Transaction

Transaction that makes use of the JDBC commit and rollback facilities directly. It relies on the connection retrieved from the dataSource to manage the scope of the transaction. Delays connection retrieval until getConnection() is called. Ignores commit or rollback requests when autocommit is on.

See Also:
JdbcTransactionFactory

Field Summary
protected  boolean autoCommmit
           
protected  Connection connection
           
protected  DataSource dataSource
           
protected  TransactionIsolationLevel level
           
 
Constructor Summary
JdbcTransaction(Connection connection)
           
JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)
           
 
Method Summary
 void close()
          Close inner database connection.
 void commit()
          Commit inner database connection.
 Connection getConnection()
          Retrieve inner database connection
protected  void openConnection()
           
protected  void resetAutoCommit()
           
 void rollback()
          Rollback inner database connection.
protected  void setDesiredAutoCommit(boolean desiredAutoCommit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected Connection connection

dataSource

protected DataSource dataSource

level

protected TransactionIsolationLevel level

autoCommmit

protected boolean autoCommmit
Constructor Detail

JdbcTransaction

public JdbcTransaction(DataSource ds,
                       TransactionIsolationLevel desiredLevel,
                       boolean desiredAutoCommit)

JdbcTransaction

public JdbcTransaction(Connection connection)
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: Transaction
Retrieve inner database connection

Specified by:
getConnection in interface Transaction
Returns:
DataBase connection
Throws:
SQLException

commit

public void commit()
            throws SQLException
Description copied from interface: Transaction
Commit inner database connection.

Specified by:
commit in interface Transaction
Throws:
SQLException

rollback

public void rollback()
              throws SQLException
Description copied from interface: Transaction
Rollback inner database connection.

Specified by:
rollback in interface Transaction
Throws:
SQLException

close

public void close()
           throws SQLException
Description copied from interface: Transaction
Close inner database connection.

Specified by:
close in interface Transaction
Throws:
SQLException

setDesiredAutoCommit

protected void setDesiredAutoCommit(boolean desiredAutoCommit)

resetAutoCommit

protected void resetAutoCommit()

openConnection

protected void openConnection()
                       throws SQLException
Throws:
SQLException


Copyright © 2010-2012 MyBatis.org. All Rights Reserved.