spring-framework / org.springframework.orm.jpa.vendor / HibernateJpaVendorAdapter / setPrepareConnection

setPrepareConnection

open fun setPrepareConnection(prepareConnection: Boolean): Unit

Set whether to prepare the underlying JDBC Connection of a transactional Hibernate Session, that is, whether to apply a transaction-specific isolation level and/or the transaction's read-only flag to the underlying JDBC Connection.

See HibernateJpaDialect#setPrepareConnection(boolean) for details. This is just a convenience flag passed through to HibernateJpaDialect.

On Hibernate 5.1/5.2, this flag remains true by default like against previous Hibernate versions. The vendor adapter manually enforces Hibernate's new connection handling mode DELAYED_ACQUISITION_AND_HOLD in that case unless a user-specified connection handling mode property indicates otherwise; switch this flag to false to avoid that interference.

NOTE: For a persistence unit with transaction type JTA e.g. on WebLogic, the connection release mode will never be altered from its provider default, i.e. not be forced to DELAYED_ACQUISITION_AND_HOLD by this flag. Alternatively, set Hibernate 5.2's "hibernate.connection.handling_mode" property to "DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION" or even "DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT" in such a scenario.

Since
4.3.1

See Also
PersistenceUnitInfo#getTransactionType()#getJpaPropertyMap(PersistenceUnitInfo)HibernateJpaDialect#beginTransaction