View Full Version : Commit and Rollback options

11-16-2007, 11:18 AM
We are using annotation driven transaction management in our application.

There are three layers
application layer -> layer1 -> layer2

application layer : PROPAGATION.REQUIRES_NEW

The issue we are facing is in the application layer I have to catch and process a run time exception .

But when we do that we are getting the following exception
ERROR org.codehaus.xfire.handler.DefaultFaultHandler - Fault occurred!
org.springframework.transaction.UnexpectedRollback Exception: Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:626)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.commitTransactionAfterReturning (TransactionAspectSupport.java:314)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:117)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :166)

so in the exception handling code we used the TransactionAspectSupport.currentTransactionStatus( ).setRollbackOnly();

This doesn't give the earlier exception but it roll backs the trx i.e. doesn't commit the changes to the DB

How can we catch the exception and at the same time commit changes to the DB.

Mark Pollack
11-16-2007, 02:30 PM

It sounds like you should declare a no-rollback rule, this will commit the transaction for work done up to where the exception was thrown. See the reference doc section Rolling Back (http://static.springframework.org/spring/docs/2.5.x/reference/transaction.html#transaction-declarative-rolling-back) for some more information.


BTW, This is the Spring .NET forum, the forum for Java related question is at forum.springframework.org (http://forum.springframework.org)