Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot transaction manager timeout

I am using the spring-boot-starter-data-jpa from Spring Boot 1.4.2.

Everything works fine (@Entity classes discovery, datasource autoconfiguration, transaction autoconfiguration, EntityManager autoconfiguration).

I can not find where the Transaction timeout can bet set. Since I want to use Spring Boot as deep as possible, I do not wish to declare programmatically a transaction manager bean in any Config file.

The "common application properties reference" only mention timeouts for JTA Transaction managers, but none for the autoconfigure one for simple JPA use. Note that I am not looking for the jdbc query timeout.

Any ideas ?

like image 979
Pierre Primot Avatar asked Nov 16 '16 10:11

Pierre Primot


People also ask

How do I set a Spring transaction timeout?

@Transactional Timeouts One way we can implement a request timeout on database calls is to take advantage of Spring's @Transactional annotation. It has a timeout property that we can set. The default value for this property is -1, which is equivalent to not having any timeout at all.

What is default transaction timeout in Spring?

The default timeout for all transactions managed by the transaction manager is 60 seconds.

What does @transactional do in Spring boot?

The @Transactional annotation is the metadata that specifies the semantics of the transactions on a method. We have two ways to rollback a transaction: declarative and programmatic. In the declarative approach, we annotate the methods with the @Transactional annotation.

What are the default @transactional settings?

The default @Transactional settings are: The propagation setting is PROPAGATION_REQUIRED. The isolation level is ISOLATION_DEFAULT. The transaction is read/write.


1 Answers

It seems that newer versions supports it with

spring.transaction.default-timeout= # Default transaction timeout in seconds.
like image 56
Pierre Primot Avatar answered Oct 13 '22 01:10

Pierre Primot