my dog learned polymorphism*
The moose likes Spring and the fly likes Spring transaction rollback aop config Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring transaction rollback aop config" Watch "Spring transaction rollback aop config" New topic
Author

Spring transaction rollback aop config

Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
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

Joined: Jul 05, 2005
Posts: 1936
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.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Andy,
it should work.

Try defining transaction attributes for both methods , for save Required and for test Supports.


Sandeep
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring transaction rollback aop config
 
Similar Threads
Challenge ! Hibernate, Spring and the Transactions...
Spring AOP, How does this example do it?
Managing hibernate transactions involving sessions from multiple sessionFactories
Spring Transaction using AOP in EJB Project
Transaction demarcation works with TransactionProxy but not AOP