Does Spring connection close after transaction?

I recently read in one tutorial that Spring closes a connection after a transaction.

It's true? I cannot find anything about this in the Spring help documentation.

What is the reason for this? Since then, I thought there was a one-to-many relationship between the connection and the transactions.

+4
source share
2 answers

Spring calls close() when the transaction ends, which may be due to either commit or rollback. Regardless of whether close() really closes the actual JDBC connection, it depends on the configuration of the DataSource . If this is a simple JDBC connection, then it actually closes. If this is a connection pool, then it will probably just be returned to the pool when it closes.

+6
source

No, the connection is closed only when the SessionFactory bean is destroyed.

0
source

Source: https://habr.com/ru/post/1496754/


All Articles