chapter thirteen
13 Using transactions in Spring apps
This chapter covers
- What transactions are and how they work
- How Spring manages transactions
- Using transactions in a Spring app
When we work with data, accuracy is not optional. An application can run correctly from a technical point of view and still leave the system in a wrong state if we don’t carefully control how data changes. This problem becomes especially important when one operation depends on several smaller steps that must all succeed together.
A transaction is a defined set of data-changing operations that must either complete successfully as a whole or not be applied at all. This property is called atomicity. Transactions are essential in applications because they help keep data consistent when one step of a use case fails after the application has already changed some data.