Win a flower (🌹) or copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java (📚) this week in the Agile and Other Processes 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
master stewards:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
garden masters:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
gardeners:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Spring transaction rollback aop config

 
pioneer
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?
 
pioneer
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.
 
pioneer
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
pioneer
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
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!