Quick revision
The short answer
No transaction starts because placeAll() calls place() on this, the real OrderService object, rather than on the Spring proxy that wraps it, and only calls that pass through the proxy run the transaction advice. The fix depends on what we want: move place() into another bean so the call goes through that bean's proxy, or put @Transactional on placeAll() if the whole batch should be one transaction. Other options are injecting the bean's own proxy with @Lazy, using TransactionTemplate, or AspectJ weaving, and the same self-invocation problem affects @Async, @Cacheable and @Retryable.
What to remember
In this answer, we saw that placeAll() calls place() on this, the target, so the call never reaches the proxy and no transaction starts. The fixes are to move place() into another bean, to annotate placeAll() if the batch should be one transaction, or to use self-injection with @Lazy, TransactionTemplate or AspectJ weaving. Choosing between one transaction per order and one for the batch is a business decision the fix should make deliberately, and the same self-invocation limit applies to @Async, @Cacheable and @Retryable.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
No transaction starts because placeAll() calls place() on this, the real OrderService object, rather than on the Spring proxy that wraps it, and only calls that pass through the proxy run the transaction advice. The fix depends on what we want: move place() into another bean so the call goes through that bean's proxy, or put @Transactional on placeAll() if the whole batch should be one transaction. Other options are injecting the bean's own proxy with @Lazy, using TransactionTemplate, or AspectJ weaving, and the same self-invocation problem affects @Async, @Cacheable and @Retryable.
Why this question is asked
This is probably the most common Spring surprise in code reviews: the annotation is right there on the method, and still nothing happens. Interviewers ask it early because it reveals whether we understand how Spring adds behaviour to beans. In this answer, we will recap how the transaction proxy works, prove that no transaction is active, see why the call skips the proxy, go through the fixes in order of preference, decide which transaction boundary we really want, and note the other annotations that share the problem.
1A Quick Recap of the Transaction Proxy
When a bean has @Transactional methods, Spring wraps it in a proxy, a generated object that looks like the bean from outside, usually a CGLIB subclass in Spring Boot. Every other bean that depends on OrderService is injected with the proxy, not the real object. When a caller invokes a method, the proxy checks whether that method is transactional; if so, it begins a transaction, calls the real object, called the target, and then commits or rolls back. The transaction logic lives only in the proxy.
2Seeing the Problem
We can check directly whether a transaction is active by asking TransactionSynchronizationManager inside place().
Notice that the same method prints true when called from the controller and false when called from placeAll(). The annotation works; the call path is what differs. The method reference this::place makes it explicit, but a plain place(o) inside the class is exactly the same call on this.
3Why the Call Skips the Proxy
The controller calls placeAll() on the proxy. placeAll() is not transactional, so the proxy forwards the call to the target without starting anything. From then on we are executing inside the target object. When placeAll() calls place(), Java dispatches the call on this, the target, and the proxy is not involved at all. No interceptor runs, so no transaction begins, and each repo.save() runs in its own auto-committed operation.
5 messages in order. Play them, or step through them one at a time.
Only calls entering through the proxy can start a transaction.
4Fix 1: Move place() Into Another Bean
The cleanest fix is to move place() into a separate bean and call it through injection. The call then crosses a bean boundary and enters through that bean's proxy.
This keeps the proxy model working as designed and makes the structure visible: placing one order is its own transactional unit.
5Fix 2: Decide Whether the Batch Is One Transaction
Before choosing a fix, we should ask what the business wants. If three orders are placed and the third fails, should the first two stay placed? With one transaction per order (Fix 1), yes. If the answer is all or nothing, then the right fix is simply to put @Transactional on placeAll(). The controller's call enters through the proxy, a single transaction starts, and the place() calls run inside it, since the self-call needs no proxy when a transaction is already active. Either is correct; the bug made the choice by accident, and the fix should make it on purpose.
6Other Options and Their Costs
Three other fixes exist. Self-injection means injecting the bean's own proxy, with @Lazy so Spring can resolve the reference to itself, and calling self.place(o); it works but hides the trick and creates a circular reference, which Spring Boot forbids by default unless the reference is lazy. TransactionTemplate starts the transaction in code, tx.executeWithoutResult(s -> place(o)), which is explicit and works inside the class regardless of proxies. AspectJ weaving, with @EnableTransactionManagement(mode = AdviceMode.ASPECTJ), puts the transaction logic into the bytecode so self-calls are advised, at the cost of a compiler or weaving agent in every build and environment.
The same problem affects every proxy-based annotation. A self-call to an @Async method runs synchronously on the caller's thread, a self-call to a @Cacheable method never consults the cache, and a self-call to a @Retryable method is never retried. Whenever an annotation seems to be ignored, the first thing to check is whether the call came through the proxy.
7Follow-up questions
Does marking the whole class @Transactional fix it?
No. Every public method becomes transactional, but placeAll() then starts one transaction for the whole batch, and place() simply joins it as a plain call. That may be what we want, but it is Fix 2 by accident, not a fix for the self-call.
Would the result differ with a JDK dynamic proxy?
No. Whether the proxy implements an interface or subclasses the class, the target's this is the target itself. Self-calls bypass both kinds of proxy in the same way.
How can a test catch this?
An integration test can call placeAll() with an order whose inventory reservation fails, then assert that the order row was rolled back. With the bug, the row remains, so the test fails. A unit test with mocks would never see it, because no proxy exists there.
8Conclusion
In this answer, we saw that placeAll() calls place() on this, the target, so the call never reaches the proxy and no transaction starts. The fixes are to move place() into another bean, to annotate placeAll() if the batch should be one transaction, or to use self-injection with @Lazy, TransactionTemplate or AspectJ weaving. Choosing between one transaction per order and one for the batch is a business decision the fix should make deliberately, and the same self-invocation limit applies to @Async, @Cacheable and @Retryable.
Open with
This is the self-invocation problem. Spring applies @Transactional through a proxy around OrderService, and other beans are injected with that proxy. The controller calls placeAll on the proxy, placeAll is not transactional, so the proxy just forwards to the real object.
Then, if they want more
Then placeAll calls place on this, which is the real object, not the proxy, so the call never passes the transaction interceptor and no transaction starts. You can prove it by logging TransactionSynchronizationManager.isActualTransactionActive inside place: it is false from placeAll and true when the controller calls place directly. The fix depends on what we want.
If each order should be its own transaction, I move place into a separate bean and call it through injection, so the call goes through that bean's proxy. If the batch should be all or nothing, I put @Transactional on placeAll instead.
Other options are injecting the proxy of itself with @Lazy, using TransactionTemplate to make the boundary explicit in code, or switching to AspectJ mode, but I would only use those for a reason.
And the same thing happens with @Async, @Cacheable, @Retryable and the security annotations, so whenever an annotation seems ignored, I check whether the call went through the proxy.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Why does no transaction start here?": https://scrivio-interview-library.netlify.app/spring-boot/aop/6ff1575075/