TransactionContextTerminal, enabling specific transaction options
such as setting the transaction as read-only, defining isolation levels,
and managing the lifecycle of transactions through commit and rollback.
Instances of this class allow for transaction customisation and chaining of configuration clauses, facilitating flexible transactional behaviour for various use cases.
-
Field Summary
Fields inherited from class org.litebridgedb.orm.api.tx.TransactionContextTerminal
isolation, readOnly, transactionManager -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.litebridgedb.orm.api.tx.TransactionContextTerminal
begin, execute
-
Constructor Details
-
TransactionContext
-
-
Method Details
-
readOnly
Indicates that the transaction should be read-only.Read-only transactions are used when the transaction is intended to only read data and not modify it.
- Returns:
- Available clauses for transaction configuration chaining
-
isolation
Sets the transaction isolation level for the current thread.The isolation level determines the degree of isolation provided for transactions, affecting how changes made by one transaction are visible to other transactions.
- Returns:
- Available clauses for transaction configuration chaining
-
commit
public void commit()Commits the current transaction.This method finalises all operations performed during the transaction and applies any changes to the underlying database. After a successful commit, the transaction is no longer active.
- Throws:
IllegalStateException- if there is no active transaction to commitTransactionException- if an error occurs during the commit process
-
rollback
public void rollback()Rolls back the current transaction.This method undoes all changes made during the active transaction. It reverts the state of the underlying data store to the point before the transaction began. After a successful rollback, the transaction is no longer active.
It should be called in cases where the transaction cannot be successfully completed, such as when an error occurs during the operations performed within the transaction.
- Throws:
IllegalStateException- if there is no active transaction to roll backTransactionException- if an error occurs during the rollback process
-