Back Forum Reply New

multiple transactions without nesting...

Looking to do something like this. This right now execute non-transactionally.  I would like each method to do a begin and commit.Code:
@Transactional( propagation=Propagation.NEVER)
public void operation() {op1(); // a transactionop2(); // a transactionop3(); // a transaction
}

@Transactional(propagation = Propagation.REQUIRED)
public op1() { }

@Transactional(propagation = Propagation.REQUIRED)
public op2() { }

@Transactional(propagation = Propagation.REQUIRED)
public op3() { }Bah, wait I think because the method are in the same class, I'm not actually call through the proxy to call to them.  If I put the op() methods in a different class then it works.

Does anyone know how I could keep them in the same class?

You must use Aspectj.

The second idea is to use programmatic transaction instead of declarative

I'm not sure if this is the best solution, but you could also inject in the object a reference to itself and use it to call op1, op2 and op3.  The reference will be proxied so transactional behavior will be applied when you call these methods.

Cheers,
GB


Originally Posted by spiffI'm not sure if this is the best solution, but you could also inject in the object a reference to itself and use it to call op1, op2 and op3.  The reference will be proxied so transactional behavior will be applied when you call these methods.

Cheers,
GB

Right. But i just think injecting itself to get transaction proxy is very unnatural.But it is just my aesthetic feeling
¥
Back Forum Reply New