beautypg.com

18 using spring transaction manager, Why transaction management is required, Spring transaction management – HP Integrity NonStop H-Series User Manual

Page 371: Declarative transaction management, Programmatic transaction management, Example of using spring transaction manager, Chapter 18: using spring transaction manager

background image

18 Using Spring Transaction Manager

This section describes how a Spring application can manage its database transactions using a
Spring Transaction Manager. This is demonstrated by modifying the EmpInfo application
(developed in

Getting Started with Spring

chapter) using the Eclipse IDE.

The following topics are discussed in this section:

Why Transaction Management is required

Spring Transaction Management

Example of Using Spring Transaction Manager

Why Transaction Management is required

A transaction is an inseparable unit of work comprising several operations, all or none of which
must be performed to preserve data integrity.

A transaction may contain one or more SQL statements, all of which can be either committed
(applied to the database) or rolled back (undone from the database) simultaneously. Thus,
whenever a set of operations needs to be implemented or completed simultaneously and if any
error occurs during any of the operation, the whole set of operations must be undone. This is
done using the Transaction Manager.

Spring Transaction Management

The Spring framework enables you to leverage the complete transaction support. It provides the
following ways for managing transactions:

Declarative Transaction Management

Programmatic Transaction Management

Declarative Transaction Management

The Declarative Transaction Management in Spring uses the Spring Aspect Oriented Programming
(AOP) feature to implement transactions on a particular business logic class. This option has
minimum impact on the application code and hence is widely used.

Programmatic Transaction Management

In Programmatic Transaction Management, the transaction manager is handled within the
application code.

A programmatic transaction can be a Java Database Connectivity (JDBC) or Java Transaction
API (JTA) transaction. In the Spring framework, programmatic transaction management can be
done using:

TransactionTemplate: uses a callback approach to free application code and release
transactional resources.

PlatformTransactionManagerImplementation: uses an instance of

org.springframework.transaction.PlatformTransactionManager

and initiates

transactions using the

TransactionDefinition

and

TransactionStatus

objects.

Example of Using Spring Transaction Manager

This section describes how business transactions in a Spring application (EmpInfo) can be managed
using the Declarative approach and the Programmatic approach.

Why Transaction Management is required

371

This manual is related to the following products: