Interface JdbcTransactionManager
- All Superinterfaces:
TransactionManager
- All Known Implementing Classes:
DataSourceTransactionManager
TransactionManager.
Carries the three members that only make sense against a JDBC DataSource -
raw Connection access and the two connection-level knobs a transaction can tune before
any statement runs. A non-JDBC backend (a JSON snapshot manager, for instance) implements
TransactionManager directly and never has to answer these three, instead of inheriting
abstract methods it can only lie about (D-04).
Framework internals that genuinely need a Connection - TransactionAwareDataSource,
AbstractRelationalDataOperator - should program against this sub-interface, not against
TransactionManager directly.
- Since:
- 6.3.0
- Author:
- wisdomme
-
Method Summary
Modifier and TypeMethodDescriptionGets the current connection, creating a new one if necessary.voidsetIsolationLevel(int level) Sets the isolation level for the current transaction.voidsetReadOnly(boolean readOnly) Sets read-only mode for the current transaction.Methods inherited from interface com.ultikits.ultitools.interfaces.TransactionManager
begin, commit, getTimeoutDeadlineNanos, getTransactionDepth, hasActiveTransaction, resume, rollback, setTimeout, suspend
-
Method Details
-
getConnection
Connection getConnection()Gets the current connection, creating a new one if necessary.If a transaction is active, returns the connection associated with it. Otherwise, returns a new connection from the data source.
- Specified by:
getConnectionin interfaceTransactionManager- Returns:
- the current connection
-
setIsolationLevel
void setIsolationLevel(int level) Sets the isolation level for the current transaction.Must be called after begin() and before any statements are executed.
- Specified by:
setIsolationLevelin interfaceTransactionManager- Parameters:
level- the JDBC isolation level constant
-
setReadOnly
void setReadOnly(boolean readOnly) Sets read-only mode for the current transaction.- Specified by:
setReadOnlyin interfaceTransactionManager- Parameters:
readOnly- true for read-only mode
-