Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring transaction rollback aop config  RSS feed

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a question regarding rolling back Spring transactions using aop definitions.



If I call service.save(), and save() throws a RuntimeException then everything works fine - the transaction is successfully rolled back.

However if I call service.test(), and all test() does is call save(), then the transaction never gets rolled back.

Thoughts?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you mean service.test() calls this.save(), it will not work.
Because Spring AOP is a proxy-based. It'll work only if the method is called directly from client code.
 
Sandeep Awasthi
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy,
it should work.

Try defining transaction attributes for both methods , for save Required and for test Supports.
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you mean service.test() calls this.save(), it will not work.
Because Spring AOP is a proxy-based. It'll work only if the method is called directly from client code.


This is what I was looking for.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!