Reputation: 165
I would like to annotate my ServiceActivator with Transactional as below :
@ServiceActivator
@Transactional(rollbackFor = Exception.class)
public Message<MyResult> populate(List<Things> th) {
// inserting in database
// try { throwing an exception } catch...
//doing other stuffs (insersions)
}
I expect to rollback the insersions after throwing an exception.
Unfortunately it dosen't work, I got the insersions in database.
Thanks in advance.
Upvotes: 1
Views: 469
Reputation: 121262
Just to close this topic, I'm providing the answer here. Even if it looks like hijacking it from Gary Russell. Although we are from the same team.
So, the @Transactional
as many other aspects in Spring must be enabled. For this purpose there is a special @Enable...
annotation - @EnableTransactionManagement
. This one scans for the PlatformTransactionManager
bean and applies AOP Advices to the methods marked with the @Transactional
.
See Reference Manual for more information.
Upvotes: 1