When I started learning Spring, I noticed something about many of the tutorials I found.
They often showed how to use a feature, but not always why it worked or when you should choose one approach over another.
I learn best by building things and documenting what I discover, so I started a project called spring-by-example.
The idea is simple: instead of building one large application, Iโm creating a collection of small, focused examples where each example explores a specific Spring concept with clear explanations, tests, and documentation.
Iโm happy to say that Iโve now completed Module 8 โ Transactions. ๐
The module covers:
@Transactional- Transaction Propagation
- Isolation Levels
- Rollback Rules
- Programmatic Transactions
TransactionProxyFactoryBean
One of the most interesting parts of this module was understanding what actually happens when Spring manages a transaction.
For example, @Transactional makes it possible to declaratively define transaction boundaries without having to manually begin, commit, or roll back transactions in application code.
Transaction propagation introduced another important concept: what should happen when a transactional method calls another transactional method?
I explored propagation behaviors such as REQUIRED and REQUIRES_NEW, and how they affect whether operations participate in the same transaction or run in an independent transaction.
Isolation levels then showed another side of transaction management: how concurrent transactions interact with data and what kinds of visibility and consistency guarantees they provide.
Rollback rules were another useful area to explore. A transaction does not necessarily roll back for every exception automatically, so understanding how Spring determines whether a transaction should be rolled back is important when designing transactional services.
I also explored programmatic transactions, which provide more explicit control over transaction boundaries when declarative transaction management isn't the right fit.
Finally, I looked at TransactionProxyFactoryBean, an older Spring approach to applying transaction management through proxies. It was especially useful for understanding how Spring's transaction infrastructure evolved and how it connects to the proxy concepts explored in the previous AOP module.
The goal isnโt just to collect Spring annotations and APIs. Iโm trying to understand how the Spring container works, how its features fit together, and why these features exist, one concept at a time.
The project is open source, and Iโm continuing to build it as I learn:
๐ GitHub: githu.b/sbe
๐ GitLab: gitla.b/sbe
Thereโs still a long way to go, but completing another module feels like a good milestone. ๐
Next up: Spring JDBC โ continuing to explore how Spring works with databases and how its abstractions simplify database access.
If youโve worked with Spring before, what part of Spring's transaction management do you think developers commonly misunderstand?
Top comments (0)