Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using @Transactional with jtaTransactionManager

 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I'm writing code to schedule sending emails to users with different frequencies, using Spring and Quartz. In my code, I first save the data related to email(to, from, content etc details) in a database table and then I save the scheduling frequency information in quartz tables. here is the method:


This is how I set JTATransactionManager in spring config:

I thought that if the statement fails then the data entered by the statement should be rolled back, but it doesn't.

Please tell where i'm making a mistake.

Thanks in advance.
 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer:

By default, the rollback is done only for runtime exceptions and not when a checked exception is thrown. I set the element "rollbackFor=Exception.class" with the @Transactional and now rollback happens for all exceptions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic