public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter
JpaVendorAdapter
implementation for Hibernate
EntityManager. Developed and tested against Hibernate 3.6, 4.2/4.3 as well as 5.0.
Hibernate 4.2+ is strongly recommended for use with Spring 4.0+.
Exposes Hibernate's persistence provider and EntityManager extension interface,
and adapts AbstractJpaVendorAdapter
's common configuration settings.
Also supports the detection of annotated packages (through
SmartPersistenceUnitInfo.getManagedPackages()
),
e.g. containing Hibernate FilterDef
annotations,
along with Spring-driven entity scanning which requires no persistence.xml
(LocalContainerEntityManagerFactoryBean.setPackagesToScan(java.lang.String...)
).
Note that the package location of Hibernate's JPA support changed from 4.2 to 4.3:
from org.hibernate.ejb.HibernateEntityManager(Factory)
to
org.hibernate.jpa.HibernateEntityManager(Factory)
. As of Spring 4.0,
we're exposing the correct, non-deprecated variant depending on the Hibernate
version encountered at runtime, in order to avoid deprecation log entries.
HibernateJpaDialect
,
HibernatePersistence
,
HibernateEntityManager
Constructor and Description |
---|
HibernateJpaVendorAdapter() |
Modifier and Type | Method and Description |
---|---|
protected Class<?> |
determineDatabaseDialectClass(Database database)
Determine the Hibernate database dialect class for the given target database.
|
Class<? extends EntityManagerFactory> |
getEntityManagerFactoryInterface()
Return the vendor-specific EntityManagerFactory interface
that the EntityManagerFactory proxy is supposed to implement.
|
Class<? extends EntityManager> |
getEntityManagerInterface()
Return the vendor-specific EntityManager interface
that this provider's EntityManagers will implement.
|
HibernateJpaDialect |
getJpaDialect()
Return the vendor-specific JpaDialect implementation for this
provider, or
null if there is none. |
Map<String,Object> |
getJpaPropertyMap()
Return a Map of vendor-specific JPA properties,
typically based on settings in this JpaVendorAdapter instance.
|
PersistenceProvider |
getPersistenceProvider()
Return the vendor-specific persistence provider.
|
String |
getPersistenceProviderRootPackage()
Return the name of the persistence provider's root package
(e.g.
|
getDatabase, getDatabasePlatform, isGenerateDdl, isShowSql, postProcessEntityManagerFactory, setDatabase, setDatabasePlatform, setGenerateDdl, setShowSql
public PersistenceProvider getPersistenceProvider()
JpaVendorAdapter
public String getPersistenceProviderRootPackage()
JpaVendorAdapter
getPersistenceProviderRootPackage
in interface JpaVendorAdapter
getPersistenceProviderRootPackage
in class AbstractJpaVendorAdapter
public Map<String,Object> getJpaPropertyMap()
JpaVendorAdapter
Note that there might be further JPA properties defined on the EntityManagerFactory bean, which might potentially override individual JPA property values specified here.
getJpaPropertyMap
in interface JpaVendorAdapter
getJpaPropertyMap
in class AbstractJpaVendorAdapter
null
or an empty Map
if there are no such properties to exposePersistence.createEntityManagerFactory(String, java.util.Map)
,
PersistenceProvider.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map)
protected Class<?> determineDatabaseDialectClass(Database database)
database
- the target databasenull
if none foundpublic HibernateJpaDialect getJpaDialect()
JpaVendorAdapter
null
if there is none.getJpaDialect
in interface JpaVendorAdapter
getJpaDialect
in class AbstractJpaVendorAdapter
public Class<? extends EntityManagerFactory> getEntityManagerFactoryInterface()
JpaVendorAdapter
If the provider does not offer any EntityManagerFactory extensions,
the adapter should simply return the standard
EntityManagerFactory
class here.
getEntityManagerFactoryInterface
in interface JpaVendorAdapter
getEntityManagerFactoryInterface
in class AbstractJpaVendorAdapter
public Class<? extends EntityManager> getEntityManagerInterface()
JpaVendorAdapter
If the provider does not offer any EntityManager extensions,
the adapter should simply return the standard
EntityManager
class here.
getEntityManagerInterface
in interface JpaVendorAdapter
getEntityManagerInterface
in class AbstractJpaVendorAdapter