spring-framework / org.springframework.orm.jpa.vendor / HibernateJpaDialect / 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.

Default is "true" on Hibernate EntityManager 4.x (with its 'on-close' connection release mode.

If you turn this flag off, JPA transaction management will not support per-transaction isolation levels anymore. It will not call Connection.setReadOnly(true) for read-only transactions anymore either. If this flag is turned off, no cleanup of a JDBC Connection is required after a transaction, since no Connection settings will get modified.

NOTE: The default behavior in terms of read-only handling changed in Spring 4.1, propagating the read-only status to the JDBC Connection now, analogous to other Spring transaction managers. This may have the effect that you're running into read-only enforcement now where previously write access has accidentally been tolerated: Please revise your transaction declarations accordingly, removing invalid read-only markers if necessary.

Since
4.1

See Also
java.sql.Connection#setTransactionIsolationjava.sql.Connection#setReadOnly