Transaction management strategies in Spring

Spring provides comprehensive support for transaction management in a Spring application. This is one the most compelling features of the Spring Framework. Mostly, this feature forces software industries to develop enterprise applications with the Spring Framework. The Spring Framework provides a consistent way to manage transactions across the application using any persistence technology, such as Java Transaction API , JDBC, Hibernate, Java Persistence API, and Java Data Objects. Spring supports declarative transaction management as well as programmatic transaction management.

There are two types of Java transactions, which are as follows:

  • Local transactions - single resource: Local transactions managed by the underlying resource; these are resource-specific. Let's explain this with the help of the following diagram:

As you can see in the preceding diagram, there is a transaction working between the application and the database platforms to ensure that every unit of task follows the ACID property of the databases.

  • Global (distributed) transactions - multiple: Global transactions, which are managed by separate, dedicated transaction managers, enable you to work with multiple transactional resources. Take a look at the following diagram to understand more about Global or distributed transactions:

As you can see in the last diagram, a Transaction Manager works with multiple database technologies in the application. A global transaction is independent of platform-specific persistence technologies.

Spring provides the same API for both types of transactions in Java applications. The Spring Framework provides a consistent programming model in any environment by either configuring the transactions declaratively, or by configuring the transaction programmatically.

Let's move on to the following sections to see how to configure transactions in Spring applications.

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

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