We all use @Transactional. But what actually handles the commit and rollback? Spring doesn’t magically modify your method. It wraps your bean in a proxy. So the real flow is: Client → Proxy → TransactionManager → Your Logic → Commit / Rollback What the proxy basically does: • Start transaction (autoCommit = false) • Bind connection to current thread (ThreadLocal) • Execute your method • If everything’s fine → commit • If RuntimeException happens → rollback Small but important detail: By default, Spring does not roll back on checked exceptions. And that’s usually where “why didn’t this rollback?” bugs come from. Understanding proxy-based transactions helps you debug: • Self-invocation issues • Async breaking transactions • Unexpected commits in prod Using @Transactional is easy. Knowing what’s happening behind it? That’s real backend depth. #SpringBoot #Java #BackendEngineering
Wow smooth and detailed info, looking forward for more such conceptual posts!
Debosmit Choudhury Understanding @Transactional usage is basic. Understanding how it actually works internally is what separates beginner vs strong backend engineers. Here’s a complete view: https://www.garudax.id/posts/shivani-m-6bbb5621b_11howtransactionalworksinternally-activity-7439570000593702912-kiOB