0

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 {
    service1.method1(); // @Transactional
    service2.method2(); // @Transactional(propagation = Propagation.REQUIRES_NEW)
    service3.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, and the transactions never end.

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.

Yoel
  • 27
  • 7

2 Answers2

1

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

sjy
  • 99
  • 8
  • Hi, thanks for your answer, i have to say that inside this method1 method2 and method3, i am calling another methods in another services, and is there where i am defining the @Transaction anotation, i am going to edit that in that post, thanks! – Yoel Jul 29 '22 at 05:27
  • looks like connection is not getting . please check below property if spring boot spring.datasource.hikari.connection-timeout = 20000 spring.datasource.hikari.minimum-idle= 10 spring.datasource.hikari.maximum-pool-size= 100 spring.datasource.hikari.idle-timeout=10000 spring.datasource.hikari.max-lifetime= 1000 spring.datasource.hikari.auto-commit =false – sjy Jul 29 '22 at 05:44
  • Actually, i am not using hikari, i am working with jpa, saving entities with a saveAndFlush. And the problem is happening at the end of the method3, when trying to do a saveAndFlush of entities. Thanks – Yoel Jul 29 '22 at 05:50
  • I think its connection pool issue . just check the logs any pool are using . its better to use one if not exist https://www.baeldung.com/java-connection-pooling – sjy Jul 29 '22 at 05:59
  • I see, i didn't know that spring boot by defaults use hikari, i am going to read about this, thanks for the help – Yoel Jul 29 '22 at 06:18
0

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