Class JdbcTransaction
java.lang.Object
org.apache.ibatis.transaction.jdbc.JdbcTransaction
- All Implemented Interfaces:
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.- Author:
- Clinton Begin
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Connection
protected DataSource
protected TransactionIsolationLevel
protected boolean
-
Constructor Summary
ConstructorDescriptionJdbcTransaction
(Connection connection) JdbcTransaction
(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit) JdbcTransaction
(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close inner database connection.void
commit()
Commit inner database connection.Retrieve inner database connection.Get transaction timeout if set.protected void
protected void
void
rollback()
Rollback inner database connection.protected void
setDesiredAutoCommit
(boolean desiredAutoCommit)
-
Field Details
-
connection
-
dataSource
-
level
-
autoCommit
protected boolean autoCommit -
skipSetAutoCommitOnClose
protected boolean skipSetAutoCommitOnClose
-
-
Constructor Details
-
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit) -
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose) -
JdbcTransaction
-
-
Method Details
-
getConnection
Description copied from interface:Transaction
Retrieve inner database connection.- Specified by:
getConnection
in interfaceTransaction
- Returns:
- DataBase connection
- Throws:
SQLException
- the SQL exception
-
commit
Description copied from interface:Transaction
Commit inner database connection.- Specified by:
commit
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
rollback
Description copied from interface:Transaction
Rollback inner database connection.- Specified by:
rollback
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
close
Description copied from interface:Transaction
Close inner database connection.- Specified by:
close
in interfaceTransaction
- Throws:
SQLException
- the SQL exception
-
setDesiredAutoCommit
protected void setDesiredAutoCommit(boolean desiredAutoCommit) -
resetAutoCommit
protected void resetAutoCommit() -
openConnection
- Throws:
SQLException
-
getTimeout
Description copied from interface:Transaction
Get transaction timeout if set.- Specified by:
getTimeout
in interfaceTransaction
- Returns:
- the timeout
- Throws:
SQLException
- the SQL exception
-