Results 1 to 2 of 2

Thread: Commit and Rollback options

  1. #1
    Join Date
    Nov 2007
    Posts
    1

    Default Commit and Rollback options

    We are using annotation driven transaction management in our application.

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

    application layer : PROPAGATION.REQUIRES_NEW
    layer1:PROPAGATION.MANDATORY
    layer2:PROPAGATION.MANDATORY

    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.

  2. #2
    Mark Pollack is offline Spring.NET Co-Lead Spring TeamSpring User
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    1,683

    Default

    Hi,

    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 for some more information.

    Cheers,
    Mark

    BTW, This is the Spring .NET forum, the forum for Java related question is at forum.springframework.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •