JpaVendorAdapter implementation for Hibernate
EntityManager. Developed and tested against Hibernate 5.0, 5.1, 5.2 and 5.3;
backwards-compatible with Hibernate 4.3 at runtime on a best-effort basis.
A note about HibernateJpaVendorAdapter vs native Hibernate settings:
Some settings on this adapter may conflict with native Hibernate configuration rules
or custom Hibernate properties. For example, specify either AbstractJpaVendorAdapter.setDatabase(org.springframework.orm.jpa.vendor.Database) or
Hibernate's "hibernate.dialect_resolvers" property, not both. Also, be careful about
Hibernate's connection release mode: This adapter prefers ON_CLOSE behavior,
aligned with HibernateJpaDialect.setPrepareConnection(boolean), at least for non-JTA
scenarios; you may override this through corresponding native Hibernate properties.
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.
public void setPrepareConnection(boolean prepareConnection)
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.
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.
Return the name of the persistence provider's root package
(e.g. "oracle.toplink.essentials"). Will be used for
excluding provider classes from temporary class overriding.
Return a Map of vendor-specific JPA properties for the given persistence
unit, typically based on settings in this JpaVendorAdapter instance.
Note that there might be further JPA properties defined on the
EntityManagerFactory bean, which might potentially override individual
JPA property values specified here.
This implementation delegates to JpaVendorAdapter.getJpaPropertyMap() for
non-unit-dependent properties. Effectively, this PersistenceUnitInfo-based
variant only needs to be implemented if there is an actual need to react
to unit-specific characteristics such as the transaction type.
Return a Map of vendor-specific JPA properties,
typically based on settings in this JpaVendorAdapter instance.
Note that there might be further JPA properties defined on the
EntityManagerFactory bean, which might potentially override individual
JPA property values specified here.