liveBook · Manning

Chapter 13: Using transactions in Spring apps

What you will learn in chapter 13 of Spring Start Here, Second Edition

This introduction explains why transactions are needed to keep related data changes consistent when one step fails.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why transactions are needed to keep related data changes consistent when one step fails.

Key terms: transaction, atomicity, data inconsistency

13.1 Transactions

This section uses a money transfer to explain why transactions group related data changes and what commit and rollback do.

Key terms: transaction, mutable operations, atomicity, data consistency, commit, rollback

13.2 How transactions work in Spring

This section explains how Spring wraps @Transactional methods with an aspect and how exceptions affect transaction rollback.

Key terms: @Transactional, Spring AOP aspect, transaction logic, runtime exception, rollback, transactional method, aspect, checked exceptions, runtime exceptions

13.3 Using transactions in Spring apps

This section implements a transactional money transfer in Spring and tests that successful transfers persist while runtime exceptions roll back both account updates.

Key terms: transferMoney(), TransferService, AccountRepository, transaction, @Transactional, aspect, commit, roll back, runtime exception, class

13.4 Questions

This section poses review questions about transactions and Spring transaction management, with answers in Appendix A.

13.5 Summary

This section summarizes why transactions protect data consistency and how Spring applies them with @Transactional.

Where this is used later

Concepts explained in this chapter

← Chapter 12: Using data sources in Spring apps Chapter 14: Implementing data persistence with Spring Data →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.