Topic Description / Key Points Details & Key Notes Examples / Usage
Transaction Management is the
process that coordinates database
operations as a single, atomic unit,
ensuring the ACID properties Prevents partial updates and
Transaction (atomicity, consistency, isolation, maintains data integrity in Example: transferring funds between accounts must
Management durability). It ensures data case of errors or fully succeed or rollback fully.
consistency by treating multiple concurrency.
operations such that they either all
succeed (commit) or all fail
(rollback).
Rollback triggered by runtime
Declares transactions declaratively
@Transactio exceptions by default;
on methods/classes, handling @Transactional(rollbackFor=[Link])on
nal configurable
commit or rollback automatically service methods to define transaction scope.
Annotation rollbackFor/noRollbackFor
depending on outcome.
for fine control.
Defines how transactions behave DEFAULT REQUIRED joins
when a transactional method is existing transaction;
Propagation @Transactional(propagation=[Link]
called inside another transaction REQUIRES_NEW suspends
Behavior _NEW)to isolate a sub-transaction like audit logging.
(e.g., REQUIRED, current and begins new
REQUIRES_NEW). transaction.
Manages concurrency effects
Default depends on DB;
between transactions
Isolation higher isolation increases @Transactional(isolation=Isolation.READ_COMMITTE
(READ_COMMITTED,
Levels consistency but can reduce D)to avoid dirty reads in concurrent access scenarios.
SERIALIZABLE etc.) with tradeoffs
performance due to locking.
of consistency and performance.
Can customize
Specifies which exceptions cause withrollbackForornoRollback
Rollback @Transactional(rollbackFor=[Link])rolls
rollback; by default, only unchecked Forto control which
Rules back on checked SQL exceptions.
exceptions trigger rollback. exceptions cause rollback or
not.
Topic Description / Key Points Details & Key Notes Examples / Usage
Declarative Declarative uses@Transactional; Declarative preferred for
vs programmatic simplicity; programmatic UseTransactionTemplateto manually start, commit or
Programmati usesTransactionTemplatefor explicit useful for complex scenarios rollback transactions in code blocks.
c control of transactions. needing dynamic control.
@EnableTransactionManagementen Only needed explicitly in
Annotate config classes
Enabling ables annotation-driven transaction non-Boot Spring apps or
with@EnableTransactionManagementif not using
Transactions handling in Spring; auto-enabled in when customizing
Spring Boot auto-configuration.
Spring Boot. transaction managers.
Important for apps with
Manage transaction lifecycle for
multiple data sources;
Transaction different resources (JPA, JDBC, @Transactional("orderTransactionManager")for
specify@Transactional("nam
Managers JTA), specify manager bean with targeted transaction management.
e")to use specific transaction
qualifier if multiple exist.
manager.
Applied at the service layer where Keeps transaction logic
Typical business logic orchestrates multiple separate from web layer and Annotate service methods to wrap multiple DAO calls
Usage Layer data operations, keeping controllers data access for modular and into one transaction boundary.
& repos clean. maintainable code.