I am using Java5 annotations for transaction demarquation on methods.
How can I obtain the transationactionally aware proxy of the object I am currently executing in, so that the transactional annotations can be
re-evaluated over a method invocation.
Since calling a member method (another method in the same "this" instance) results in a direct Java method invocation call and does not cause Spring's transactionally aware proxying to evaluate the situation and do the correct thing.
Code:public class FooImpl { @Transactional(propagation = Propagation.REQUIRED) public Integer methodOne(int a) { int aa = a + 1; Integer i = methodTwo(aa); // Problem, REQUIRES_NEW has no effect return i; } @Transactional(propagation = Propagation.REQUIRES_NEW) public Integer methodTwo(int b) { resource.doMagic(b); return Integer.value(b); } }
This problem is well known for EJB related similar situations the following URL describe the well known work around for EJB in this situation:
http://community.jboss.org/message/525521#525521
So I am looking for the equivalent of taking "this" and getting "proxyOfFoo" (i.e. the proxy of this, that is transactionally aware).Code:FooImpl proxyOfFoo = this.sessionContext.getBusinessObject(FooImpl.class); // invoke on that business object with transaction support proxyOfFoo.methodOne(b);


Reply With Quote
