What type of transaction management strategy we should use in Spring? Declarative or Programmatic? Which one is better and under what situation one should use it? Can you give a
They are not mutually exclusive.
You can use decalrative transaction management (@Transactional
) in most of cases, and fall back to programmatic transaction management (TransactionTemplate
) when you face limitations of Spring AOP (see 11.5.1 Understanding the Spring Framework's declarative transaction implementation) or need to control transactions in more complex ways.