[jboss-user] [JBoss Seam] - Re: TransactionalSeamPhaseListener + Spring @Transactional

youngm do-not-reply at jboss.com
Tue Aug 14 11:27:11 EDT 2007


anonymous wrote : can anyone explain me the effect, when I combine Seam TransactionalSeamPhaseListener with Spring @Transctional annotation in my service layer? 

Well, first of all you need to make sure that they're configured to use the same JTA TransactionManager.  With Seam 2.0.0 CR1 you will be able to configure Seam to use a Spring PlatformTransactionManager.

So, assuming you have Spring and Seam set up to use the same JTA TM then the TransactionalSeamPhaseListener will manage transaction begin and commit semantics for a faces request.  If you call a method annotated with spring's @Transactional then by default Spring will join that transaction since the default spring propagation rule is "REQUIRED".  You could use the spring TM to gain more fine grained control over you transaction with with Spring's transaction suspension support and nested support.

If the service method is called outside of a Faces Request (e.g. @Asynchronous call) then @Transactional  would start a transaction since TransactionalSeamPhaseListener would not be available.

So in the end if in a faces request using @Transactional will have no effect unless you're using Spring's transaction suspension or nested transactions.  If not in a faces request then @Transactional can be used to start and commit transactions when interacting with your service layer.

Does that answer your question?

Mike

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074080#4074080

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074080



More information about the jboss-user mailing list