Announcement Announcement Module
Collapse
No announcement yet.
Transaction can not rollback, help me. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction can not rollback, help me.

    Hello,everyone:
    Today I meet a problem that transaction can not rollback. Spring version 2.5.6SEC02
    In my code, transaction config is:
    [ code]
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="add*" propagation="REQUIRED" />
    <tx:method name="create*" propagation="REQUIRED" />
    <tx:method name="modify*" propagation="REQUIRED" />
    <tx:method name="remove*" propagation="REQUIRED" />
    <tx:method name="manager*" propagation="REQUIRED" />
    <tx:method name="sync*" propagation="NOT_SUPPORTED"/>
    <tx:method name="*" read-only="true" propagation="SUPPORTS" />
    </tx:attributes>
    </tx:advice>
    [/code ]
    When I invoke a method named modify***, and in this method a RuntimeException is thrown. But the transaction does not rollback, and there are some dirty data in DB.
    I debug, and find getTransactionManager().rollback(txInfo.getTransac tionStatus()) does invoke. But dirty data in DB does not rollback......Then I view the result of getTransactionManager() ,and find the datasource is correct. Then I continue view txInfo.getTransactionStatus(), I find Attachment
    the rollbackOnly=false, Is it the reason?
    Attached Files
    Last edited by zwzm85; Jan 8th, 2013, 01:33 AM.

  • #2
    Please use [ code][/code ] tags when posting code that way it remains readable..

    If data doesn't rollback either your setup is wrong or your databse doesn't support transactions (MySQL with MyISAM tables for instance). Also please use the search as this question has been answered numerous times before.

    Comment


    • #3
      Hello,Marten Deinum
      In the same object, method a transaction propagation is SUPPORT, method b transaction propagation is REQUIRED. My code invoke a, and a inoke b. Then does b have a transaction?

      Comment


      • #4
        No... Spring uses proxies to apply AOP and when you are inside a proxy (internal method call) those calls aren't intercepted only external calls.

        Comment


        • #5
          Thank you, I guess that also.
          And it is answer!

          Comment

          Working...
          X