Home  >  Spring Core

Rollback-for and no-rollback-for in Spring

By Arvind Rai, February 10, 2013
In spring we can declare rollback-for for roll backing the transaction. For any exception if we want to rollback the transaction and for any other exception we donít want to rollback the transaction, we can handle it simply in spring. Define rollback-for and no-rollback-for in application xml for any exception.
<tx:advice id="txAdvice">
  <tx:attributes>
  <tx:method name="*" rollback-for="Exception" 
  no-rollback-for="IOException"/>
  </tx:attributes>
</tx:advice> 
 
In the above configuration, if application gets Exception or its sub class, exception will be roll backed automatically. And if application gets IOException, transaction will not be roll backed. If we do not get the exception which is neither rollback-for nor no-rollback-for, then most match exception will be considered.
POSTED BY
ARVIND RAI
ARVIND RAI
FIND MORE TUTORILAS


©2019 concretepage.com | Privacy Policy | Contact Us