Results 1 to 5 of 5

Thread: Transaction can not rollback, help me.

  1. #1
    Join Date
    Jan 2013
    Posts
    3

    Default 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 transaction.jpg
    the rollbackOnly=false, Is it the reason?
    Last edited by zwzm85; Jan 8th, 2013 at 01:33 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jan 2013
    Posts
    3

    Default

    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?

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jan 2013
    Posts
    3

    Default

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

Posting Permissions

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