Spring types of transactions

Spring transaction categories:


spring support programmatic transaction management and declarative transaction management in two ways:


① programmatic transaction management using TransactionTemplate.


② declarative transaction management built on AOP. Its essence is through AOP functionality, before and after the method to intercept, the braided function of the transaction to intercept method, that is adding a transaction before the target method begins, submitted in accordance with the implementation after executing the target method or roll back the transaction .


The biggest advantage declarative transaction that does not require doping transaction management code in the business logic code, just do the relevant business rules declared in the configuration file or by @Transactional annotation mode, you can apply business rules to business logic in.


Declarative transaction management is better than programmatic transaction management, which is a non-invasive way of development advocated by the spring, the business code is not contaminated, as long as annotate can get full transaction support. The only downside places that can only be applied to most fine-grained method level, you can not do as programmatic transaction that can be applied to the block level. !

Reproduced in: https: //www.jianshu.com/p/c1d63df6829c

Guess you like

Origin blog.csdn.net/weixin_34240657/article/details/91310534