View RSS Feed

Spring Framework

Transactions in Spring

Rate this Entry
by , 07-07-2012 at 06:32 PM (1179 Views)
A sequence of actions which make a single work unit is a database transaction. This sequence of actions must be completely taken effect or discarded at all. The most important part of RDBMS based enterprise applications is transaction management which ensure consistency and data integrity. Following are the four main properties of transactions which explain it.
Atomicity: A single unit of operation best describes the transaction. So that is either successful or not as a single unit of operation.
Consistency: The referential integrity must be consistent in a database like unique primary keys.
Isolation: The same dataset might be being processed at the same time by multiple transactions. The data must be handled and prevented from corruption by handaling transactions in isolation.
Durability: The results are made permanent when a transaction is completed and it is not possible to remove from database in case of system failure.
All the above four properties must be assured for a RDBMS for all transactions.
Using SQL, the transaction is issued to database using following simplistic view:
The begin transaction command is used to start a transaction.
Using SQL queries, update, delete and insert operations are performed.
Commit is performed when all operations are successful else rollback is called on the transaction.
On top of transaction management APIS, Spring framework provides an abstract layer. The transaction support is provided to POJOS as an alternate to EJB transactions. Local vs. Global Transactions in Spring.

A single transactional resource is used in the local transactions like JDBC connection. Multiple transactional resources are used in global transactions like distributed systesm transactions.
In centralized computing environment, local transaction management is usedful where resources and application components are placed at single site. A single data manager is involved in local transactions that are running on a standalone machine. Also it is easy to implement local transactions.
In distributed transaction environement, it is required to use global transaction management. In such cases multiple systems are used to distribute resources. Both and global and local level, transaction management is done is these situations. Across multiple systems, global or distributed transaction is executed and it is required to coordinate between local data managers and global transaction management system of all the involved systesm.

Submit "Transactions in Spring" to Facebook Submit "Transactions in Spring" to Digg Submit "Transactions in Spring" to del.icio.us Submit "Transactions in Spring" to StumbleUpon Submit "Transactions in Spring" to Google

Categories
JDBC

Comments