-
Jan 7th, 2013, 11:53 PM
#1
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.
-
Jan 8th, 2013, 01:13 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.
-
Jan 8th, 2013, 02:10 AM
#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?
-
Jan 8th, 2013, 02:16 AM
#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.
-
Jan 8th, 2013, 02:25 AM
#5
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
-
Forum Rules