I want to know what actually happens when you annotate a method with `@Transactional`?
Of course, I know that Spring will wrap that method in a Transaction.

But, I have the following doubts:

1. I heard that Spring creates a **proxy class**? Can someone explain this in more **depth**. **What actually resides in that proxy class? What happens to the actual class? And how can I see Spring's created proxied class**
2. I also read in Spring docs that:

> 
> *Note: Since this mechanism is based on proxies, **only 'external' method calls coming in through the proxy will be intercepted**. This means that 'self-invocation', i.e. a method within the target object calling some other method of the target object, won't lead to an actual transaction at runtime even if the invoked method is marked with `@Transactional`!*
> 
> 
> 

Source: <http://static.springsource.org/spring/docs/2.0.x/reference/transaction.html>

**Why only external method calls will be under Transaction and not the self-invocation methods?**
['https://Stackoverflow.com/questions/1099025', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/133830/']
As a visual person, I like to weigh in with a sequence diagram of the proxy pattern. If you don't know how to read the arrows, I read the first one like this: `Client` executes `Proxy.method()`.

1. The client calls a method on the target from his perspective, and is silently intercepted by the proxy
2. If a before aspect is defined, the proxy will execute it
3. Then, the actual method (target) is executed
4. After-returning and after-throwing are optional aspects that are
executed after the method returns and/or if the method throws an
exception
5. After that, the proxy executes the after aspect (if defined)
6. Finally the proxy returns to the calling client

![Proxy Pattern Sequence Diagram](https://i.imgur.com/Ye9pEVI.jpg)
(I was allowed to post the photo on condition that I mentioned its origins. Author: Noel Vaes, website: <https://www.noelvaes.eu>)
All existing answers are correct, but I feel cannot give just this complex topic.

For a comprehensive, practical explanation you might want to have a look at this [Spring @Transactional In-Depth](https://www.marcobehler.com/guides/spring-transaction-management-transactional-in-depth) guide, which tries its best to cover transaction management in ~4000 simple words, with a lot of code examples.