Sobes.tech
Junior — Middle

Will the transaction be automatically managed if a private method marked with @Transactional is called?

sobes.tech AI

Answer from AI

In Spring, transactions are managed through proxies that intercept calls to methods annotated with @Transactional. If a method is private, the call occurs within the same class directly, bypassing the proxy, so a transaction will not be created automatically.

That is, the @Transactional annotation on a private method will not work if this method is called from another method of the same class. For the transaction to work, the method must be public and called externally through the Spring proxy.

Will the transaction be automatically managed if a… - sobes.tech