Jan 7th, 2013, 11:53 PM
Transaction can not rollback, help me.
Today I meet a problem that transaction can not rollback. Spring version 2.5.6SEC02
In my code, transaction config is:
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<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" />
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
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
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
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
Thank you, I guess that also.
And it is answer!