Transaction
Definition
After creating the database connection, we use the database connection to create a transaction manager.
Transaction management in GoooQo is accomplished through the cooperation of TransactionManager and TransactionContext (TC for short).
The method TransactionManager#StartTransaction
is responsible for starting a transaction and returning TC; TC combines driver.Tx
and is responsible for transaction commit and rollback.
The TxDataAccess
interface combines TransactionManager
and DataAccess
, which can conveniently manage transactions while providing the database operations.
Usages
Use StartTransaction
to start a transaction and manually commit or rollback the transaction:
Or use SubmitTransaction
to submit the transaction via callback:
Last updated