Spring Boot Transaction Management

Gain Java Knowledge
3 min readNov 23, 2020

How Spring Boot Transaction Management Works with the @Transactional annotation and Propagation types.

The process of combining related operations into single unit and executing them by applying do everything or nothing principle is called Transaction Management.

We execute sensitive logics like ticket booking, transfer money and etc. logics by enabling transaction management support.

TRANSACTION PROPAGATION TYPE :

1. REQUIRED
2. SUPPORTS
3. MANDATORY
4. REQUIRES_NEW
5. NOT_SUPPORTED
6. NEVER
7. NESTED

1. REQUIRED :
========

  • If the addMessage() is called directly then it will create its own Transaction.
  • If the add message is called from another service –
    a. If the calling MessageService method has a transaction then method make use of the existing transaction.
    b. If the calling MessageService method does not have any transaction then the method will create new transaction.
    So in case of REQUIRED the addMessage() method makes use of the calling UserService method transaction if it exists else create its own.

--

--

Gain Java Knowledge
Gain Java Knowledge

Written by Gain Java Knowledge

The Java programming language is one of the most popular languages today. Stay up to date with news, certifications, free learning resources and much more.

No responses yet