Managing Transactions

Abstract

Database transactions help you group a set of operations into a single unit of work. All operations succeed, or fail, as a group. Spring’s powerful and flexible transaction support is another factor responsible for the framework’s success and popularity. Prior to Spring, complex or declarative transactional features typically required a JEE server. Using Aspect-Oriented-Programming (AOP) techniques, Spring helped democratize enterprise-level transactional support, allowing developers to cleanly apply transactional rules to their code whether they were using a full-fledged JEE application server, a lighter weight web container, or even a stand-alone unit test. The important detail is that the transactional rules could be consolidated into configuration so that code need not be muddied with these types of concerns. Switching between a JEE application server, using a Java Transaction API (JTA) datasource and a simple unit test, and a local datasource is just a matter of modifying the Spring configuration; no code needs to be altered. However, Spring can leverage some of the advanced features offered by JTA when employing a JTA transaction manager. The key benefit, however, is that Spring provides a transactional programming model that is consistent, whether you need to have transactions span multiple datasources (a feature offered by JTA) or across a single datasource, the way in which you define these transactional concerns will always be the same when using Spring.

Keywords

Glean 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Paul Tepper Fisher and Solomon Duskis 2009

Personalised recommendations