1

I think I have a good idea of how spring uses proxy concept with @Transactional annotation but I can't find anything about "default" implementation. Basically what I'm looking for is the code which wraps the invocation of original method (method from wrapped object).

Hynek Hrabík
  • 79
  • 1
  • 11

1 Answers1

3

There is no such thing as a default implementation because it all depends on the class implementing the method where you add the @Transactional annotation to. If that class inherits from an interface then JDK Dynamic Proxy will be used. If not, then an external library called CGLIB will be used to create the proxy. Dynamic proxy will create a proxy that implements all interfaces your target class also implements while CGLIB will create a proxy that extends your target class.

Also make sure to read this SO question concerning the difference between Dynamic Proxy and CGLIB proxy as it contains valuable information as well.

Nico Van Belle
  • 4,911
  • 4
  • 32
  • 49