Class JdbcTransaction
- java.lang.Object
-
- 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.- Author:
- Clinton Begin
- See Also:
JdbcTransactionFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
autoCommit
protected Connection
connection
protected DataSource
dataSource
protected TransactionIsolationLevel
level
protected boolean
skipSetAutoCommitOnClose
-
Constructor Summary
Constructors Constructor Description JdbcTransaction(Connection connection)
JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)
JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose)
-
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()
protected void
resetAutoCommit()
void
rollback()
Rollback inner database connection.protected void
setDesiredAutoCommit(boolean desiredAutoCommit)
-
-
-
Field Detail
-
connection
protected Connection connection
-
dataSource
protected DataSource dataSource
-
level
protected TransactionIsolationLevel level
-
autoCommit
protected boolean autoCommit
-
skipSetAutoCommitOnClose
protected boolean skipSetAutoCommitOnClose
-
-
Constructor Detail
-
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)
-
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose)
-
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 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
-
setDesiredAutoCommit
protected void setDesiredAutoCommit(boolean desiredAutoCommit)
-
resetAutoCommit
protected void resetAutoCommit()
-
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
-
-