Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Why does @Transactional on a private method have no effect, and which other Spring annotations share the same limitation?

Spring applies @Transactional through a proxy, and a proxy can only add behaviour to methods it can override or implement. A private method cannot be overridden, so the proxy never sees calls to it, and Spring silently ignores the annotation there. The same limitation applies to every proxy-based annotation, such as @Async, @Cacheable and @Retryable, and to final methods, which CGLIB proxies cannot override either; IDE inspections can warn about these cases.

Why this question is asked

An annotation that does nothing, without any warning or error, is one of the more frustrating things in Spring. A developer adds @Transactional to a private helper, the code compiles, the application starts, and the method runs without a transaction. Interviewers ask this question because the answer depends on understanding how Spring adds behaviour at runtime, and the same understanding explains a whole group of similar surprises. In this answer, we will recap how proxies work, see why private and final methods fall outside them, list the other annotations that share the limitation, and look at how to catch these mistakes early.

1A Quick Recap: How Spring Applies @Transactional

Spring does not change our compiled class to add transactions. Instead, at startup it creates a proxy, a generated object that stands in front of our bean. In Spring Boot this is by default a CGLIB proxy, a subclass of our class created at runtime, which overrides each method so that it can run the transaction logic and then call our original method. With a JDK dynamic proxy, the proxy instead implements our bean's interfaces.

Other beans receive the proxy when they inject our bean. So a call from outside goes to the overriding method in the proxy, which starts a transaction, calls the real method, and commits or rolls back afterwards.

2Why Private Methods Cannot Be Intercepted

A private method is not visible to subclasses, and in Java a subclass cannot override it. The CGLIB proxy can only override methods that are not private, not final and not static. So for a private method there is simply no place where the proxy could put its transaction logic.

There is a second reason. A private method can only be called from inside the same class, which means the call is always on this, the real object, never on the proxy. Even if the proxy could somehow wrap it, no call would ever reach the wrapper.

Java
@Service
public class ReportService {
public void rebuild() {
clearOld(); // a private call on this
}
@Transactional // silently ignored
private void clearOld() {
log.info("tx: {}", TransactionSynchronizationManager.isActualTransactionActive());
repository.deleteAllOlderThan(cutoff());
}
}
// tx: false
Which methods a CGLIB proxy can intercept
MethodIntercepted?Reason
publicYesCan be overridden
protected, package-privateYes, since Spring Framework 6.0Can be overridden by the generated subclass
privateNo, silentlyCannot be overridden; only called on this
finalNo, silentlyCannot be overridden
staticNoBelongs to the class, not the object
Any method called on thisNoThe call never reaches the proxy

Spring does not report this. The transaction attribute lookup, in its default configuration, does not consider private methods at all, so from Spring's point of view the method simply has no transactional configuration.

3Final Methods Have the Same Problem, and a Worse One

A final method cannot be overridden either, so CGLIB cannot intercept it, and the annotation is ignored in the same silent way. But final methods add a nasty twist. When an outside caller calls a final method on the proxy, the call runs the method's original code on the proxy object itself, not on our real bean. The proxy is a generated subclass whose fields were never initialised by our constructor, so injected dependencies are null.

Java
@Service
public class InvoiceService {
private final InvoiceRepository repository;
public InvoiceService(InvoiceRepository repository) { this.repository = repository; }
@Transactional
public final void issue(Invoice i) {
repository.save(i); // NullPointerException: repository is null on the proxy
}
}

This is why final methods on Spring beans produce such confusing NullPointerExceptions. Kotlin developers meet it often, because Kotlin classes and methods are final by default; the kotlin-spring compiler plugin opens classes annotated with Spring stereotypes and @Transactional for exactly this reason.

4Other Annotations With the Same Limitation

Every annotation that Spring applies through AOP proxies follows the same rules: @Async for running a method on another thread, @Cacheable, @CachePut and @CacheEvict for caching, @Retryable from Spring Retry (and the core @Retryable in Spring Framework 7), @PreAuthorize and @Secured for method security, @Validated method validation, and our own custom aspects. On a private or final method, or through a call on this, each of them is silently skipped.

The consequences vary: a method meant to run asynchronously blocks the caller, a cache that never fills, a retry that never retries, and, most seriously, a security check that never runs.

5Fixing It and Catching It Early

The fix is to make the method interceptable and call it through the proxy. Usually that means making it public (or protected or package-private on Spring Framework 6.0 and later with class-based proxies) and moving it into another bean, so the call goes from one bean to another through injection. If the method was private because it is an internal detail, a separate small bean with a clear name keeps the design honest.

Java
@Service
class ReportCleaner {
@Transactional
public void clearOld() { ... } // tx: true when called from ReportService
}
@Service
class ReportService {
private final ReportCleaner cleaner;
public void rebuild() { cleaner.clearOld(); } // through ReportCleaner's proxy
}

To catch the mistake before it reaches production, IntelliJ IDEA's Spring inspections warn when @Transactional or similar annotations are placed on private or final methods, and an ArchUnit rule can fail the build for any method that has a proxy-based annotation and is private or final. Tests that check TransactionSynchronizationManager.isActualTransactionActive() inside important methods catch the self-invocation cases too.

6Follow-up questions

Would AspectJ weaving make @Transactional on private methods work?

Yes. With AspectJ compile-time or load-time weaving, the transaction logic is woven into the class's bytecode, so private methods and self-calls are intercepted. It requires a different build or a Java agent, which is why most teams stay with proxies.

Why does Spring not throw an error for a private @Transactional method?

Because the attribute source simply does not look at private methods, so nothing in the startup process notices the annotation. Tools like IDE inspections and ArchUnit fill that gap.

Does this apply to JDK dynamic proxies too?

Even more strictly. A JDK proxy only implements the interface methods, so only public methods declared on an interface can be intercepted, and calls to any other method of the class are never transactional through the proxy.

7Conclusion

In this answer, we saw that Spring applies @Transactional with a proxy that overrides methods, so private methods, which cannot be overridden and are only called on this, are never intercepted and the annotation is silently ignored. Final methods are ignored the same way and can even run on the uninitialised proxy with null fields. The limitation is shared by @Async, the cache annotations, @Retryable, method security and custom aspects, and IDE inspections, ArchUnit rules and simple tests catch it early.

What to say in the interviewAbout 90 seconds aloud

Open with

Spring implements @Transactional with a proxy. In Spring Boot that's a CGLIB subclass of the bean, generated at startup, which overrides each method to start the transaction and then calls the real method.

Then, if they want more

A private method can't be overridden, so there's nowhere for the proxy to put the transaction logic, and on top of that a private method is only ever called from inside the class, on this, so the call wouldn't reach the proxy anyway.

Spring doesn't consider private methods when it looks for transaction attributes, so the annotation is just ignored, silently, and the method runs without a transaction.

Final methods have the same issue, CGLIB can't override them, and there's an extra trap: an outside call to a final method runs on the proxy instance itself, whose fields were never injected, so you get NullPointerExceptions. That bites Kotlin teams because Kotlin is final by default, which is why the kotlin-spring plugin opens those classes.

The same rules apply to every proxy-based annotation: @Async, @Cacheable and the cache annotations, @Retryable, @PreAuthorize and other method security, and custom aspects. Since Spring 6.0, protected and package-private methods work with class-based proxies, but private never does. The fix is to make the method interceptable and call it through another bean.

To catch it early, IntelliJ inspections warn about it, and an ArchUnit rule can fail the build.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 6, Spring Framework 7
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.
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 @Transactional on a private method have no effect, and which other Spring...": https://scrivio-interview-library.netlify.app/databases/transactions/cb6c48ba73/