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
posted
0
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
posted
0
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
posted
0
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.