[Spring Boot] Transactional Propagation Properties

In this article, different propagation properties will be tested.

Test code will make use of two services. To make it easier to distinguish the hierarchy of the two services, I will name them as ParentService and ChildService.

ParentService Implementation

To make things simpler, ParentService simply saves some data and invokes ChildService like below:

ParentService Implementation

For some transactional propagation properties (MANDATORY, SUPPORTS, NEVER, NOT_SUPPORTED, NESTED), some methods in ParentService will not be annotated with Transactional to see the effects of parent transaction.

ChildService Implementation

ChildService will simply save some data and trigger a runtime exception to see if certain transaction propagation performs rollback or not. Each method will be annotated with a different propagation property to see how each behaves. A sample would look like below:

ChildService Implementation

Transaction Propagation

Full source:

References: