Implementation of Spring transactions

Implementation of Spring transactions





Implementation of Spring transactions

Spring transactions are consistent with database transactions

There are two main ways to implement Spring transactions: programmatic transaction management and declarative transaction management.

  • ① Programmatic transaction management uses TransactionTemplate.
  • ② Declarative transaction management is based on AOP. Its essence is to intercept the method before and after the method through the AOP function, and weave the transaction processing function into the intercepted method, that is, start a transaction before the target method starts, and submit or roll back the transaction according to the execution status after the target method is executed. .
声明式事务管理的优点:
   不需要掺杂业务逻辑代码,@Transactional注解可以被添加到类级别和方法级别上。
声明式事务管理的缺点:
   无法做到细粒度的事务控制,无法做到像编程式事务那样可以作用到代码块级别。比如一个事务方法调用了多个DAO方法,希望其中某个DAO方法独立成为一个事务,这时候就办不到了。






My Github address , welcome everyone to join my open source project, or (contact me on my homepage) to join your open source project, click Github-Stars.

\ open source project name dependent type version number describe
1 spring-boot-starter-trie pom 1.0.0-SNAPSHOT The query speed under specific requirements far exceeds that of open source search tools, and the B+ tree under innodb or the inverted index in ES cannot compare with it.
2 spring-boot-starter-trie jar 1.0.0-M1 Provides SpringCloud-based service nodes, which can be used for service discovery through the Nacos registry, realizing dynamic expansion and contraction of the tree, and dynamic online and offline services.
3 Data-Provider pom 1.0.0-SNAPSHOT It provides queries from multiple data sources and data type synchronization. As a Jar, it can rely on dynamically providing data on other services.

Guess you like

Origin blog.csdn.net/jj89929665/article/details/130884272