Spring transaction management

Spring's transaction support provides an abstraction over different transaction APIs, including the Java Transaction API (JTA) that works with global transactions, as well as the JDBC API, Hibernate transaction API, and JPA transaction API. The latter three APIs work with local transactions.

A global transaction can work with multiple transaction resources, typically relational database and message queues (JMS). And it is the application server that manages global transactions through JTA. On the other hand, a local transaction is resource-specific, for example, a transaction associated with a JDBC connection. Local transactions cannot work with multiple resources.

Spring transaction management supports both programmatic and declarative transaction management. You can use Spring's TransactionTemplate API to manage transactions programmatically or use the PlatformTransactionManager API directly. For declarative transaction management, you can apply the @Transactional annotation to the classes or methods where you want transaction management. The implementation of Spring's declarative transaction management is based on Spring's AOP framework, and it works in any environment for both global or local transactions. 

Both programmatic and declarative transaction management support rollback rules, in other words, you can declare what exceptions can or cannot cause automatic rollback.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.10.45