Closed willome closed 1 year ago
For a Spring app that uses the default JpaTransactionManager
, the default connection release mode should be the right one, at least on Hibernate 5.
Related to the setPrepareConnection
, the default is true
, meaning that you can set the isolation level and the read-only flag on the Connection
.
Setting this to false
is not really an improvement, in my opinion.
In my transaction routing example, I didn't have to set this property, so maybe it's not needed anymore.
Hi Vlad,
Even if I am not sure about that, the hibernate hibernate.connection.handling_mode should be set to DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION for non JTA environments, especially with a spring application.
SpringFramework keeps the legacy mode (really ?) and we also could set the JpaDialect like this ((HibernateJpaVendorAdapter) bean).getJpaDialect().setPrepareConnection(false)
I really do not know if it is a good idea or not, but according to this old thread, it could be an improvement.
And with a spring application, that was the only way to make the RoutingDataSource effectively working (see https://stackoverflow.com/questions/68012475/how-to-do-database-routing-in-read-only-and-read-write-with-spring).