MainOverviewWikiIssuesForumBuildFisheye

Chapter 26. Spring Transaction

26.1. Introduction

Compass::Spring integrates with Spring transaction management in several ways, either using Compass::Core own LocalTransaction or using the Spring transaction synchronization services. Currently there is no Compass implementation of Spring's PlatformTransactionManagement.

26.2. LocalTransaction

Compass::Core default transaction handling is LocalTransaction. A LocalTransaction does not integrate with Spring transaction management services, but can be used to write Compass Dao beans that do not require integration with an on going Spring or Jta transactions.

26.3. JTASyncTransaction

When using Spring's JtaTransactionManager, you have a choice to either use the SpringSycnTransaction (described next) or the JTASyncTransaction provided by Compass::Core (where SpringSyncTransaction is preferable).

26.4. SpringSyncTransaction

Compass::Spring integrates with Spring transaction synchronization services. This means that whichever Spring transaction manager (Jta, Hiberante, ...) you are using, the SpringSyncTransaction will synchronize with the transaction upon transaction completion.

If you are using the SpringSyncTransaction, a Spring based transaction must already be started in order for SpringSyncTransaction to join. If no transcation is started, Compass can start one (and will commit it eventually) if the PlatformTransactionManager is provided to the LocalCompassBean. The transaction must support the transaction synchronization feature (which by default all of them do).

Note: you can use spring transaction management support to suspend and resumed transactions. In which case a Compass provided transaction will be suspended and resumed also.

In order to configure Compass to work with the SpringSyncTransaction, you must set the compass.transaction.factory to org.compass.spring.transaction.SpringSyncTransactionFactory.

26.5. CompassTransactionManager

Currently Compass::Spring does not provide a CompassTransactionManager. This means any CompassDao objects with LocalTransaction, programmatic (Spring transction template) / declarative (Spring Interceptor/AOP transaction support) Spring transaction definition won't be applied to the Compass transaction.