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.ManagedTransactionFactory
Constructor and Description |
---|
ManagedTransaction(Connection connection,
boolean closeConnection) |
ManagedTransaction(DataSource ds,
TransactionIsolationLevel level,
boolean closeConnection) |
Modifier and Type | Method and 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.
|
public ManagedTransaction(Connection connection, boolean closeConnection)
public ManagedTransaction(DataSource ds, TransactionIsolationLevel level, boolean closeConnection)
public Connection getConnection() throws SQLException
Transaction
getConnection
in interface Transaction
SQLException
- the SQL exceptionpublic void commit() throws SQLException
Transaction
commit
in interface Transaction
SQLException
- the SQL exceptionpublic void rollback() throws SQLException
Transaction
rollback
in interface Transaction
SQLException
- the SQL exceptionpublic void close() throws SQLException
Transaction
close
in interface Transaction
SQLException
- the SQL exceptionprotected void openConnection() throws SQLException
SQLException
public Integer getTimeout() throws SQLException
Transaction
getTimeout
in interface Transaction
SQLException
- the SQL exceptionCopyright © 2009–2021 MyBatis.org. All rights reserved.