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

HibernateJpaVendorAdapter

open class HibernateJpaVendorAdapter : AbstractJpaVendorAdapter

org.springframework.orm.jpa.JpaVendorAdapter implementation for Hibernate EntityManager. Developed and tested against Hibernate 5.0, 5.1 and 5.2; backwards-compatible with Hibernate 4.3 at runtime on a best-effort basis.

Exposes Hibernate's persistence provider and EntityManager extension interface, and adapts AbstractJpaVendorAdapter's common configuration settings. Also supports the detection of annotated packages (through org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo#getManagedPackages()), e.g. containing Hibernate org.hibernate.annotations.FilterDef annotations, along with Spring-driven entity scanning which requires no persistence.xml (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setPackagesToScan).

Author
Juergen Hoeller

Author
Rod Johnson

Since
2.0

See Also
HibernateJpaDialect

Constructors

<init>

HibernateJpaVendorAdapter()

Functions

getEntityManagerFactoryInterface

open fun getEntityManagerFactoryInterface(): Class<out EntityManagerFactory>

getEntityManagerInterface

open fun getEntityManagerInterface(): Class<out EntityManager>

getJpaDialect

open fun getJpaDialect(): HibernateJpaDialect

getJpaPropertyMap

open fun getJpaPropertyMap(pui: PersistenceUnitInfo): MutableMap<String, Any?>
open fun getJpaPropertyMap(): MutableMap<String, Any?>

getPersistenceProvider

open fun getPersistenceProvider(): PersistenceProvider

getPersistenceProviderRootPackage

open fun getPersistenceProviderRootPackage(): String

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.