Class ManagedTransaction
- java.lang.Object
-
- org.apache.ibatis.transaction.managed.ManagedTransaction
-
- All Implemented Interfaces:
Transaction
public class ManagedTransaction extends Object implements Transaction
Transaction
that lets the container manage the full lifecycle of the transaction. Delays connection retrieval until getConnection() is called. Ignores all commit or rollback requests. By default, it closes the connection but can be configured not to do it.- Author:
- Clinton Begin
- See Also:
ManagedTransactionFactory
-
-
Constructor Summary
Constructors Constructor Description ManagedTransaction(Connection connection, boolean closeConnection)
ManagedTransaction(DataSource ds, TransactionIsolationLevel level, boolean closeConnection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close inner database connection.void
commit()
Commit inner database connection.Connection
getConnection()
Retrieve inner database connection.Integer
getTimeout()
Get transaction timeout if set.protected void
openConnection()
void
rollback()
Rollback inner database connection.
-
-
-
Constructor Detail
-
ManagedTransaction
public ManagedTransaction(Connection connection, boolean closeConnection)
-
ManagedTransaction
public ManagedTransaction(DataSource ds, TransactionIsolationLevel level, boolean closeConnection)
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
Description copied from interface:Transaction
Retrieve inner database connection.- Specified by:
getConnection
in interfaceTransaction
- Returns:
- DataBase connection
- Throws:
SQLException
- the SQL exception
-
commit
public void commit() throws SQLException
Description copied from interface:Transaction
Commit inner database connection.- Specified by:
commit
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
rollback
public void rollback() throws SQLException
Description copied from interface:Transaction
Rollback inner database connection.- Specified by:
rollback
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
close
public void close() throws SQLException
Description copied from interface:Transaction
Close inner database connection.- Specified by:
close
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
openConnection
protected void openConnection() throws SQLException
- Throws:
SQLException
-
getTimeout
public Integer getTimeout() throws SQLException
Description copied from interface:Transaction
Get transaction timeout if set.- Specified by:
getTimeout
in interfaceTransaction
- Returns:
- the timeout
- Throws:
SQLException
- the SQL exception
-
-