• Post Reply Bookmark Topic Watch Topic
  • New Topic

ThreadLocal and TransactionRollback  RSS feed

 
Chandra shekar M
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to keep the threadLocal in sync with transactionroll back, how do i do it?



So how do i keep threadlocal in sync with transactions?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I have no idea where or what @Transaction(Reuired) does (not standard Java I don't think), but if you want to revert the ThreadLocal value back if an exception happen you will need to:
1) Cache a copy of the value as you enter the method.
2) Catch all exceptions, revert the value to the cached value
3) Probably re-throw the exception so if triggers any other exception handling mechanisms exist.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!