Generally. A database transaction symbolizes a unit of work performed within a database management system (or
similar system) against a database, and treated in a coherent and reliable way independent of other
transactions. A transaction generally represents any change in a database.
- Begin transaction
- Execute set of changes / queries
- Start Commit:
- If no error occurs, then commit the transaction
- If error occurs, then roll back the transaction
Transactional models:
- Local - JDBC
- Programmatic - JPA
- Declarative - Spring Annotations
Transactional workflow:
@Transactional Settings
The default @Transactional settings are as follows:
- The propagation setting is PROPAGATION_REQUIRED.
- The isolation level is ISOLATION_DEFAULT.
- The transaction is read-write.
- The transaction timeout defaults to the default timeout of the underlying transaction system, or to none
if timeouts are not supported.
- Any RuntimeException triggers rollback, and any checked Exception does not.
Transaction propagations:
- MANDATORY
- NESTED
- NEVER
- NOT_SUPPORTED
- REQUIRES_NEW
- SUPPORTS
Isolation levels:
- DEFAULT
- READ_UNCOMMITTED
- READ_COMMITTED
- REPEATABLE_READ
- SERIALIZABLE
Programmatic Transaction Management
The Spring Framework provides two means of programmatic transaction management, by using:
- The TransactionTemplate or TransactionalOperator.
- A TransactionManager implementation directly.