Home > Net >  How to use different spring transactions for different methods
How to use different spring transactions for different methods

Time:07-29

I am having a problem with the persistence of a method that is calling another methods to do persistence at my oracle db.

I will try to explain as better as i can to make more easy to you guys, I hope that you can help me.

This is my scenario.

I have a component, in which i am calling a method that looks like that:

public void execute() throws Exception {
    this.method1(); // @Transactional
    this.method2(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
    this.method3(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
}

The thing is that i need to persist every method separately in case that one of them gets an exception, the others could be persisted.

Right now the problem i have is that i am having a deadlock and my code stills running until i stop my application.

I tried so many things, but i am trying without the needed knowledge to work with this spring transactions and i do not know what more i can try to do.

Can you bring me some light on this dark hole where i am right now?

Really, thank you.

CodePudding user response:

Spring AOP same class method will not works . this.method1(); // @Transactional will not work.

more explanation in this thread Same class invoke NOT effective in Spring AOP cglib

CodePudding user response:

u can register different transactionManager, and ur services use its @Transactional(tx="xxx")

  • Related