Package org.hibernate.jpa
Class HibernatePersistenceConfiguration
java.lang.Object
jakarta.persistence.PersistenceConfiguration
org.hibernate.jpa.HibernatePersistenceConfiguration
Hibernate extension to the Jakarta Persistence
PersistenceConfiguration
contract.- Since:
- 7.0
- API Note:
- The specification explicitly encourages implementors to extend
PersistenceConfiguration
to accommodate vendor-specific extensions in a more typesafe way. Of course, programs which desire configuration logic to be portable between JPA providers should usePersistenceConfiguration
directly.
-
Field Summary
Fields inherited from class jakarta.persistence.PersistenceConfiguration
CACHE_MODE, JDBC_DATASOURCE, JDBC_DRIVER, JDBC_PASSWORD, JDBC_URL, JDBC_USER, LOCK_TIMEOUT, QUERY_TIMEOUT, SCHEMAGEN_CREATE_SCRIPT_SOURCE, SCHEMAGEN_CREATE_SOURCE, SCHEMAGEN_CREATE_TARGET, SCHEMAGEN_DATABASE_ACTION, SCHEMAGEN_DROP_SCRIPT_SOURCE, SCHEMAGEN_DROP_SOURCE, SCHEMAGEN_DROP_TARGET, SCHEMAGEN_SCRIPTS_ACTION, VALIDATION_FACTORY, VALIDATION_GROUP_PRE_PERSIST, VALIDATION_GROUP_PRE_REMOVE, VALIDATION_GROUP_PRE_UPDATE
-
Constructor Summary
ConstructorDescriptionCreate a new empty configuration. -
Method Summary
Modifier and TypeMethodDescriptioncaching
(CachingType type) Enable or disable the second-level and query caches.cachingAccessType
(AccessType type) If data caching is enabled, configure the type of concurrency access that should be applied if not explicitly specified on a cache region.cachingCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling of proxies.closedCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling around calls to EntityManager.close(), EntityManager.isOpen(), EntityManagerFactory.close() and EntityManagerFactory.isOpen()collectStatistics
(boolean enabled) Configures whether Hibernate should collect Statistics.Create a newSessionFactory
based on this configuration.defaultCatalog
(String catalogName) Configure a default catalog name to be used for database objects (tables, sequences, etc) which do not explicitly specify one.defaultSchema
(String schemaName) Configure a default schema name to be used for database objects (tables, sequences, etc) which do not explicitly specify one.globalGeneratorCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for in terms of collecting all named value generators globally, regardless of location.jdbcCredentials
(String username, String password) Username and password for non-DataSource
JDBC connection.jdbcDriver
(String driverName) JDBC driver class name for non-DataSource
connection.jdbcPassword
(String password) Password for non-DataSource
JDBC connection.JDBC URL of non-DataSource
JDBC connection.jdbcUsername
(String username) Username for non-DataSource
JDBC connection.jtaDataSource
(String dataSourceJndiName) loadByIdCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for the allowed type of identifier value passed toEntityManager.getReference(java.lang.Class<T>, java.lang.Object)
andEntityManager.find(java.lang.Class<T>, java.lang.Object)
managedClass
(Class<?> managedClass) managedClasses
(Class<?>... managedClasses) Add the specified classes as managed classes.managedClasses
(Collection<Class<?>> managedClasses) Add the specified classes as managed classes.mappingFile
(String name) mappingFiles
(String... names) Add the specified resource names as mapping files.mappingFiles
(Collection<String> names) Add the specified resource names as mapping files.nationalizedCharacterData
(boolean enabled) Configure a default schema name to be used for database objects (tables, sequences, etc) which do not explicitly specify one.nonJtaDataSource
(String dataSourceJndiName) orderByMappingCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for the interpretation ofOrderBy
.properties
(Map<String, ?> properties) proxyCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling of proxies.queryCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for all aspects of Query handling.schemaToolingAction
(Action action) Specify the action to take in terms of automatic database schema tooling.sharedCacheMode
(SharedCacheMode sharedCacheMode) showSql
(boolean showSql, boolean formatSql, boolean highlightSql) Enables SQL logging to the console.statementInspector
(Class<? extends StatementInspector> inspectorImpl) Specify a StatementInspector to be applied to all Sessions/EntityManagersstatementInspector
(StatementInspector inspector) Specify a StatementInspector to be applied to all Sessions/EntityManagerstransactionCompliance
(boolean enabled) Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for all aspects of transaction handling.transactionType
(PersistenceUnitTransactionType transactionType) validationMode
(ValidationMode validationMode) xmlMappings
(boolean enabled) Configures whether Hibernate should process XML mappings (orm.xml
files).xmlValidation
(boolean enabled) Configures whether Hibernate should validate (via schema descriptor) XML files.Methods inherited from class jakarta.persistence.PersistenceConfiguration
jtaDataSource, managedClasses, mappingFiles, name, nonJtaDataSource, properties, provider, sharedCacheMode, transactionType, validationMode
-
Constructor Details
-
HibernatePersistenceConfiguration
Create a new empty configuration. An empty configuration does not typically hold enough information for successful invocation ofcreateEntityManagerFactory()
.- Parameters:
name
- the name of the persistence unit, which may be used by the persistence provider for logging and error reporting
-
-
Method Details
-
createEntityManagerFactory
Create a newSessionFactory
based on this configuration.- Overrides:
createEntityManagerFactory
in classPersistenceConfiguration
-
jdbcDriver
JDBC driver class name for non-DataSource
connection.- See Also:
-
jdbcUrl
JDBC URL of non-DataSource
JDBC connection.- See Also:
-
jdbcUsername
Username for non-DataSource
JDBC connection. -
jdbcPassword
Password for non-DataSource
JDBC connection. -
jdbcCredentials
Username and password for non-DataSource
JDBC connection. -
showSql
public HibernatePersistenceConfiguration showSql(boolean showSql, boolean formatSql, boolean highlightSql) Enables SQL logging to the console.Sets "hibernate.show_sql", "hibernate.format_sql", and "hibernate.highlight_sql".
- Parameters:
showSql
- should SQL be logged to console?formatSql
- should logged SQL be formattedhighlightSql
- should logged SQL be highlighted with pretty colors
-
queryCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for all aspects of Query handling. -
transactionCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for all aspects of transaction handling. -
closedCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling around calls to EntityManager.close(), EntityManager.isOpen(), EntityManagerFactory.close() and EntityManagerFactory.isOpen() -
proxyCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling of proxies. -
cachingCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for handling of proxies. -
globalGeneratorCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for in terms of collecting all named value generators globally, regardless of location. -
orderByMappingCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for the interpretation ofOrderBy
. -
loadByIdCompliance
Specifies whether Hibernate will strictly adhere to compliance with Jakarta Persistence for the allowed type of identifier value passed toEntityManager.getReference(java.lang.Class<T>, java.lang.Object)
andEntityManager.find(java.lang.Class<T>, java.lang.Object)
-
caching
Enable or disable the second-level and query caches. -
cachingAccessType
If data caching is enabled, configure the type of concurrency access that should be applied if not explicitly specified on a cache region. -
statementInspector
public HibernatePersistenceConfiguration statementInspector(Class<? extends StatementInspector> inspectorImpl) Specify a StatementInspector to be applied to all Sessions/EntityManagers- See Also:
-
statementInspector
Specify a StatementInspector to be applied to all Sessions/EntityManagers- See Also:
-
defaultCatalog
Configure a default catalog name to be used for database objects (tables, sequences, etc) which do not explicitly specify one.- See Also:
-
defaultSchema
Configure a default schema name to be used for database objects (tables, sequences, etc) which do not explicitly specify one.- See Also:
-
nationalizedCharacterData
Configure a default schema name to be used for database objects (tables, sequences, etc) which do not explicitly specify one. -
xmlMappings
Configures whether Hibernate should process XML mappings (orm.xml
files).- See Also:
-
xmlValidation
Configures whether Hibernate should validate (via schema descriptor) XML files.- See Also:
-
collectStatistics
Configures whether Hibernate should collect Statistics.- See Also:
-
managedClasses
Add the specified classes as managed classes.- See Also:
-
managedClasses
Add the specified classes as managed classes.- See Also:
-
mappingFiles
Add the specified resource names as mapping files.- See Also:
-
mappingFiles
Add the specified resource names as mapping files.- See Also:
-
schemaToolingAction
Specify the action to take in terms of automatic database schema tooling.- See Also:
- API Note:
- This only controls tooling as exported directly to the database. To output tooling commands to scripts, use config properties instead with appropriate settings.
-
provider
- Overrides:
provider
in classPersistenceConfiguration
-
jtaDataSource
- Overrides:
jtaDataSource
in classPersistenceConfiguration
-
nonJtaDataSource
- Overrides:
nonJtaDataSource
in classPersistenceConfiguration
-
managedClass
- Overrides:
managedClass
in classPersistenceConfiguration
-
mappingFile
- Overrides:
mappingFile
in classPersistenceConfiguration
-
transactionType
public HibernatePersistenceConfiguration transactionType(PersistenceUnitTransactionType transactionType) - Overrides:
transactionType
in classPersistenceConfiguration
-
validationMode
- Overrides:
validationMode
in classPersistenceConfiguration
-
property
- Overrides:
property
in classPersistenceConfiguration
-
properties
- Overrides:
properties
in classPersistenceConfiguration
-