Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Spring transaction rollback aop config

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic