Declarative or Programmatic Transaction in Spring

后端 未结 6 1542
小蘑菇
小蘑菇 2021-02-03 10:27

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

6条回答
  •  广开言路
    2021-02-03 11:11

    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.

提交回复
热议问题