Configurations
Strategy configurations
Many configuration settings define pluggable strategies that Hibernate uses for various purposes. The configuration of many of these strategy type settings accept definition in various forms. The documentation of such configuration settings refer here. The types of forms available in such cases include:
- short name (if defined)
-
Certain built-in strategy implementations have a corresponding short name.
- strategy instance
-
An instance of the strategy implementation to use can be specified
- strategy Class reference
-
A
java.lang.Classreference of the strategy implementation to use - strategy Class name
-
The class name (
java.lang.String) of the strategy implementation to use
General Configuration
hibernate.dialect(e.g.org.hibernate.dialect.PostgreSQL94Dialect)-
The classname of a Hibernate
Dialectfrom which Hibernate can generate SQL optimized for a particular relational database.In most cases Hibernate can choose the correct
Dialectimplementation based on the JDBC metadata returned by the JDBC driver. hibernate.current_session_context_class(e.g.jta,thread,managed, or a custom class implementingorg.hibernate.context.spi.CurrentSessionContext)-
Supply a custom strategy for the scoping of the current
Session.The definition of what exactly current means is controlled by the
CurrentSessionContextimplementation in use.Note that for backwards compatibility, if a
CurrentSessionContextis not configured but JTA is configured this will default to theJTASessionContext.
Database connection properties
hibernate.connection.driver_classorjavax.persistence.jdbc.driver(e.g.org.postgresql.Driver)-
Names the JDBC
Driverclass name. hibernate.connection.urlorjavax.persistence.jdbc.url(e.g.jdbc:postgresql:hibernate_orm_test)-
Names the JDBC connection URL.
hibernate.connection.usernameorjavax.persistence.jdbc.user-
Names the JDBC connection user name.
hibernate.connection.passwordorjavax.persistence.jdbc.password-
Names the JDBC connection password.
hibernate.connection.isolation(e.g.REPEATABLE_READorConnection.TRANSACTION_REPEATABLE_READ)-
Names the JDBC connection transaction isolation level.
hibernate.connection.autocommit(e.g.trueorfalse(default value))-
Names the initial autocommit mode for JDBC Connections returned from a connection pool created in certain ConnectionProvider impl.
See discussion of
hibernate.connection.provider_disables_autocommitas well. hibernate.connection.provider_disables_autocommit(e.g.trueorfalse(default value))-
Indicates a promise by the user that Connections that Hibernate obtains from the configured ConnectionProvider have auto-commit disabled when they are obtained from that provider, whether that provider is backed by a DataSource or some other Connection pooling mechanism. Generally this occurs when:
-
Hibernate is configured to get Connections from an underlying DataSource, and that DataSource is already configured to disable auto-commit on its managed Connections
-
Hibernate is configured to get Connections from a non-DataSource connection pool and that connection pool is already configured to disable auto-commit. For the Hibernate provided implementation this will depend on the value of
hibernate.connection.autocommitsetting.Hibernate uses this assurance as an opportunity to opt-out of certain operations that may have a performance impact (although this impact is general negligible). Specifically, when a transaction is started via the Hibernate or JPA transaction APIs Hibernate will generally immediately acquire a Connection from the provider and:
-
check whether the Connection is initially in auto-commit mode via a call to
Connection#getAutocommitto know how to clean up the Connection when released. -
start a JDBC transaction by calling
Connection#setAutocommit(false)We can skip both of those steps if we know that the ConnectionProvider will always return Connections with auto-commit disabled. That is the purpose of this setting. By setting it to
true, theConnectionacquisition can be delayed until the first SQL statement is needed to be executed. The connection acquisition delay allows you to reduce the database connection lease time, therefore allowing you to increase the transaction throughput.It is inappropriate to set this value to
truewhen the Connections Hibernate gets from the provider do not, in fact, have auto-commit disabled.Doing so will lead to Hibernate executing SQL operations outside of any JDBC/SQL transaction.
-
hibernate.connection.datasource-
Either a
javax.sql.DataSourceinstance or a JNDI name under which to locate theDataSource.For JNDI names, ses also
hibernate.jndi.class,hibernate.jndi.url,hibernate.jndi. hibernate.connection-
Names a prefix used to define arbitrary JDBC connection properties. These properties are passed along to the JDBC provider when creating a connection.
hibernate.connection.provider_class(e.g.org.hibernate.hikaricp.internal. HikariCPConnectionProvider)-
Names the
ConnectionProviderto use for obtaining JDBC connections.Can reference:
-
an instance of
ConnectionProvider -
a
Class<? extends ConnectionProviderobject reference -
a fully qualified name of a class implementing
ConnectionProviderThe term
classappears in the setting name due to legacy reasons; however it can accept instances.
-
hibernate.jndi.class-
Names the JNDI
javax.naming.InitialContextclass. hibernate.jndi.url(e.g. java:global/jdbc/default)-
Names the JNDI provider/connection url.
hibernate.jndi-
Names a prefix used to define arbitrary JNDI
javax.naming.InitialContextproperties.These properties are passed along to
javax.naming.InitialContext#InitialContext(java.util.Hashtable) hibernate.connection.acquisition_mode(e.g.immediate)-
Specifies how Hibernate should acquire JDBC connections. The possible values are given by
org.hibernate.ConnectionAcquisitionMode.Should generally only configure this or
hibernate.connection.release_mode, not both. hibernate.connection.release_mode(e.g.auto(default value))-
Specifies how Hibernate should release JDBC connections. The possible values are given by the current transaction mode (
after_transactionfor JDBC transactions andafter_statementfor JTA transactions).Should generally only configure this or
hibernate.connection.acquisition_mode, not both.
Hibernate internal connection pool options
hibernate.connection.initial_pool_size(e.g. 1 (default value))-
Minimum number of connections for the built-in Hibernate connection pool.
hibernate.connection.pool_size(e.g. 20 (default value))-
Maximum number of connections for the built-in Hibernate connection pool.
hibernate.connection.pool_validation_interval(e.g. 30 (default value))-
The number of seconds between two consecutive pool validations. During validation, the pool size can increase or decreases based on the connection acquisition request count.
c3p0 properties
hibernate.c3p0.min_size(e.g. 1)-
Minimum size of C3P0 connection pool. Refers to c3p0
minPoolSizesetting. hibernate.c3p0.max_size(e.g. 5)-
Maximum size of C3P0 connection pool. Refers to c3p0
maxPoolSizesetting. hibernate.c3p0.timeout(e.g. 30)-
Maximum idle time for C3P0 connection pool. Refers to c3p0
maxIdleTimesetting. hibernate.c3p0.max_statements(e.g. 5)-
Maximum size of C3P0 statement cache. Refers to c3p0
maxStatementssetting. hibernate.c3p0.acquire_increment(e.g. 2)-
Number of connections acquired at a time when there’s no connection available in the pool. Refers to c3p0
acquireIncrementsetting. hibernate.c3p0.idle_test_period(e.g. 5)-
Idle time before a C3P0 pooled connection is validated. Refers to c3p0
idleConnectionTestPeriodsetting. hibernate.c3p0-
A setting prefix used to indicate additional c3p0 properties that need to be passed to the underlying c3p0 connection pool.
Mapping Properties
Table qualifying options
hibernate.default_catalog(e.g. A catalog name)-
Qualifies unqualified table names with the given catalog in generated SQL.
hibernate.default_schema(e.g. A schema name)-
Qualify unqualified table names with the given schema or tablespace in generated SQL.
hibernate.schema_name_resolver(e.g. The fully qualified name of anorg.hibernate.engine.jdbc.env.spi.SchemaNameResolverimplementation class)-
By default, Hibernate uses the
org.hibernate.dialect.Dialect#getSchemaNameResolver. You can customize how the schema name is resolved by providing a custom implementation of theSchemaNameResolverinterface.
Identifier options
hibernate.id.new_generator_mappings(e.g.true(default value) orfalse)-
Setting which indicates whether or not the new
IdentifierGeneratorare used forAUTO,TABLEandSEQUENCE.Existing applications may want to disable this (set it
false) for upgrade compatibility from 3.x and 4.x to 5.x. hibernate.use_identifier_rollback(e.g.trueorfalse(default value))-
If true, generated identifier properties are reset to default values when objects are deleted.
hibernate.id.optimizer.pooled.preferred(e.g.none,hilo,legacy-hilo,pooled(default value),pooled-lo,pooled-lotlor a fully-qualified name of theOptimizerimplementation)-
When a generator specified an increment-size and an optimizer was not explicitly specified, which of the pooled optimizers should be preferred?
hibernate.jpa.compliance.global_id_generators(e.g.trueorfalse(default value) )-
The JPA spec says that the scope of TableGenerator and SequenceGenerator names is global to the persistence unit (across all generator types).
Traditionally, Hibernate has considered the names locally scoped.
If enabled, the names used by
@TableGeneratorand@SequenceGeneratorwill be considered global so configuring two different generators with the same name will cause a `java.lang.IllegalArgumentException' to be thrown at boot time. ==== Quoting options hibernate.globally_quoted_identifiers(e.g.trueorfalse(default value))-
Should all database identifiers be quoted.
hibernate.globally_quoted_identifiers_skip_column_definitions(e.g.trueorfalse(default value))-
Assuming
hibernate.globally_quoted_identifiersistrue, this allows the global quoting to skip column-definitions as defined byjavax.persistence.Column,javax.persistence.JoinColumn, etc, and while it avoids column-definitions being quoted due to global quoting, they can still be explicitly quoted in the annotation/xml mappings. hibernate.auto_quote_keyword(e.g.trueorfalse(default value))-
Specifies whether to automatically quote any names that are deemed keywords.
Discriminator options
hibernate.discriminator.implicit_for_joined(e.g.trueorfalse(default value))-
The legacy behavior of Hibernate is to not use discriminators for joined inheritance (Hibernate does not need the discriminator). However, some JPA providers do need the discriminator for handling joined inheritance so, in the interest of portability, this capability has been added to Hibernate too.
Because want to make sure that legacy applications continue to work as well, that puts us in a bind in terms of how to handle implicit discriminator mappings. The solution is to assume that the absence of discriminator metadata means to follow the legacy behavior unless this setting is enabled.
With this setting enabled, Hibernate will interpret the absence of discriminator metadata as an indication to use the JPA-defined defaults for these absent annotations.
See Hibernate Jira issue HHH-6911 for additional background info.
hibernate.discriminator.ignore_explicit_for_joined(e.g.trueorfalse(default value))-
The legacy behavior of Hibernate is to not use discriminators for joined inheritance (Hibernate does not need the discriminator). However, some JPA providers do need the discriminator for handling joined inheritance so, in the interest of portability, this capability has been added to Hibernate too.
Existing applications rely (implicitly or explicitly) on Hibernate ignoring any
DiscriminatorColumndeclarations on joined inheritance hierarchies. This setting allows these applications to maintain the legacy behavior ofDiscriminatorColumnannotations being ignored when paired with joined inheritance.See Hibernate Jira issue HHH-6911 for additional background info.
Naming strategies
hibernate.implicit_naming_strategy(e.g.default(default value),jpa,legacy-jpa,legacy-hbm,component-path)-
Used to specify the
ImplicitNamingStrategyclass to use. The following short names are defined for this setting:defaultjpalegacy-jpa-
Uses the
ImplicitNamingStrategyLegacyJpaImpl legacy-hbm-
Uses the
ImplicitNamingStrategyLegacyHbmImpl component-path-
Uses the
ImplicitNamingStrategyComponentPathImplIf this property happens to be empty, the fallback is to use
defaultstrategy.
hibernate.physical_naming_strategy(e.g.org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl(default value))-
Used to specify the
PhysicalNamingStrategyclass to use.
Metadata scanning options
hibernate.archive.scanner-
Pass an implementation of
Scanner. By default,StandardScanneris used.Accepts either:
-
an actual
Scannerinstance -
a reference to a Class that implements
Scanner -
a fully qualified name of a Class that implements
Scanner
-
hibernate.archive.interpreter-
Pass
ArchiveDescriptorFactoryto use in the scanning process.Accepts either:
-
an actual
ArchiveDescriptorFactoryinstance -
a reference to a Class that implements
ArchiveDescriptorFactory -
a fully qualified name of a Class that implements
ArchiveDescriptorFactorySee information on
Scannerabout expected constructor forms.
-
hibernate.archive.autodetection(e.g.hbm,class(default value))-
Identifies a comma-separate list of values indicating the mapping types we should auto-detect during scanning.
Allowable values include:
class-
scan classes (e.g.
.class) to extract entity mapping metadata hbm-
scan
hbmmapping files (e.g.hbm.xml) to extract entity mapping metadataBy default both HBM, annotations, and JPA XML mappings are scanned.
When using JPA, to disable the automatic scanning of all entity classes, the
exclude-unlisted-classespersistence.xmlelement must be set to true. Therefore, when settingexclude-unlisted-classesto true, only the classes that are explicitly declared in thepersistence.xmlconfiguration files are going to be taken into consideration.
hibernate.mapping.precedence(e.g.hbm,class(default value))-
Used to specify the order in which metadata sources should be processed. Value is a delimited-list whose elements are defined by
MetadataSourceType.Default is
hbm,class", thereforehbm.xmlfiles are processed first, followed by annotations (combined withorm.xmlmappings).When using JPA, the XML mapping overrides a conflicting annotation mapping that targets the same entity attribute.
JDBC-related options
hibernate.use_nationalized_character_data(e.g.trueorfalse(default value))-
Enable nationalized character support on all string / clob based attribute ( string, char, clob, text etc ).
hibernate.jdbc.lob.non_contextual_creation(e.g.trueorfalse(default value))-
Should we not use contextual LOB creation (aka based on
java.sql.Connection#createBlob()et al)? The default value for HANA, H2, and PostgreSQL istrue. hibernate.jdbc.time_zone(e.g. Ajava.util.TimeZone, ajava.time.ZoneIdor aStringrepresentation of aZoneId)-
Unless specified, the JDBC Driver uses the default JVM time zone. If a different time zone is configured via this setting, the JDBC PreparedStatement#setTimestamp is going to use a
Calendarinstance according to the specified time zone. hibernate.dialect.oracle.prefer_long_raw(e.g.trueorfalse(default value))-
This setting applies to Oracle Dialect only, and it specifies whether
byte[]orByte[]arrays should be mapped to the deprecatedLONG RAW(when this configuration property value istrue) or to aBLOBcolumn type (when this configuration property value isfalse).
Bean Validation options
javax.persistence.validation.factory(e.g.javax.validation.ValidationFactoryimplementation)-
Specify the
javax.validation.ValidationFactoryimplementation to use for Bean Validation. hibernate.check_nullability(e.g.trueorfalse)-
Enable nullability checking. Raises an exception if a property marked as not-null is null.
Default to
falseif Bean Validation is present in the classpath and Hibernate Annotations is used,trueotherwise. hibernate.validator.apply_to_ddl(e.g.true(default value) orfalse)-
Bean Validation constraints will be applied in DDL if the automatic schema generation is enabled. In other words, the database schema will reflect the Bean Validation constraints.
To disable constraint propagation to DDL, set up
hibernate.validator.apply_to_ddltofalsein the configuration file. Such a need is very uncommon and not recommended.
Misc options
hibernate.create_empty_composites.enabled(e.g.trueorfalse(default value))-
Enable instantiation of composite/embeddable objects when all of its attribute values are
null. The default (and historical) behavior is that anullreference will be used to represent the composite when all of its attributes arenull.This is an experimental feature that has known issues. It should not be used in production until it is stabilized. See Hibernate Jira issue HHH-11936 for details.
hibernate.entity_dirtiness_strategy(e.g. fully-qualified class name or an actualCustomEntityDirtinessStrategyinstance)-
Setting to identify a
org.hibernate.CustomEntityDirtinessStrategyto use. hibernate.default_entity_mode(e.g.pojo(default value) ordynamic-map)-
Default
EntityModefor entity representation for all sessions opened from thisSessionFactory, defaults topojo.
Bytecode Enhancement Properties
hibernate.enhancer.enableDirtyTracking(e.g.trueorfalse(default value))-
Enable dirty tracking feature in runtime bytecode enhancement.
hibernate.enhancer.enableLazyInitialization(e.g.trueorfalse(default value))-
Enable lazy loading feature in runtime bytecode enhancement. This way, even basic types (e.g.
@Basic(fetch = FetchType.LAZY)) can be fetched lazily. hibernate.enhancer.enableAssociationManagement(e.g.trueorfalse(default value))-
Enable association management feature in runtime bytecode enhancement which automatically synchronizes a bidirectional association when only one side is changed.
hibernate.bytecode.provider(e.g.javassist(default value))-
The
BytecodeProviderbuilt-in implementation flavor. Currently, onlyjavassistis supported. hibernate.bytecode.use_reflection_optimizer(e.g.trueorfalse(default value))-
Should we use reflection optimization? The reflection optimizer implements the
ReflectionOptimizerinterface and improves entity instantiation and property getter/setter calls.
Query settings
hibernate.query.plan_cache_max_size(e.g.2048(default value))-
The maximum number of entries including:
HQLQueryPlan,FilterQueryPlan,NativeSQLQueryPlan.Maintained by
QueryPlanCache. hibernate.query.plan_parameter_metadata_max_size(e.g.128(default value))-
The maximum number of strong references associated with
ParameterMetadatamaintained byQueryPlanCache. hibernate.order_by.default_null_ordering(e.g.none,firstorlast)-
Defines precedence of null values in
ORDER BYclause. Defaults tononewhich varies between RDBMS implementation. hibernate.discriminator.force_in_select(e.g.trueorfalse(default value))-
For entities which do not explicitly say, should we force discriminators into SQL selects?
hibernate.query.substitutions(e.g.true=1,false=0)-
A comma-separated list of token substitutions to use when translating a Hibernate query to SQL.
hibernate.query.factory_class(e.g.org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory(default value) ororg.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory)-
Chooses the HQL parser implementation.
hibernate.query.jpaql_strict_compliance(e.g.trueorfalse(default value))-
Map from tokens in Hibernate queries to SQL tokens, such as function or literal names.
Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support all of Hibernate’s superset (HQL)?
Setting this to
truemay cause valid HQL to throw an exception because it violates the JPQL subset. hibernate.query.startup_check(e.g.true(default value) orfalse)-
Should named queries be checked during startup?
hibernate.proc.param_null_passing(e.g.trueorfalse(default value))-
Global setting for whether
nullparameter bindings should be passed to database procedure/function calls as part ofProcedureCallhandling. Implicitly Hibernate will not pass thenull, the intention being to allow any default argument values to be applied.This defines a global setting, which can then be controlled per parameter via
org.hibernate.procedure.ParameterRegistration#enablePassingNulls(boolean)Values are
true(pass the NULLs) orfalse(do not pass the NULLs). hibernate.jdbc.log.warnings(e.g.trueorfalse)-
Enable fetching JDBC statement warning for logging. Default value is given by
org.hibernate.dialect.Dialect#isJdbcLogWarningsEnabledByDefault(). hibernate.session_factory.statement_inspector(e.g. A fully-qualified class name, an instance, or aClassobject reference)-
Names a
StatementInspectorimplementation to be applied to everySessioncreated by the currentSessionFactory.Can reference a
StatementInspectorinstance,StatementInspectorimplementationClassreference orStatementInspectorimplementation class name (fully-qualified class name). hibernate.query.validate_parameters(e.g.true(default value) orfalse)-
This configuration property can be used to disable parameters validation performed by
org.hibernate.query.Query#setParameterwhen the the Session is bootstrapped via JPAjavax.persistence.EntityManagerFactory hibernate.criteria.literal_handling_mode(e.g.AUTO(default value),BINDorINLINE)-
By default, Criteria queries uses bind parameters for any literal that is not a numeric value. However, to increase the likelihood of JDBC statement caching, you might want to use bind parameters for numeric values too.
The
org.hibernate.query.criteria.LiteralHandlingMode#BINDmode will use bind variables for any literal value. Theorg.hibernate.query.criteria.LiteralHandlingMode#INLINEmode will inline literal values as-is.To prevent SQL injection, never use
org.hibernate.query.criteria.LiteralHandlingMode#INLINEwith String variables. Always use constants with theorg.hibernate.query.criteria.LiteralHandlingMode#INLINEmode.Valid options are defined by the
org.hibernate.query.criteria.LiteralHandlingModeenum. The default value isorg.hibernate.query.criteria.LiteralHandlingMode#AUTO.
Multi-table bulk HQL operations
hibernate.hql.bulk_id_strategy(e.g. A fully-qualified class name, an instance, or aClassobject reference)-
Provide a custom
org.hibernate.hql.spi.id.MultiTableBulkIdStrategyimplementation for handling multi-table bulk HQL operations. hibernate.hql.bulk_id_strategy.global_temporary.drop_tables(e.g.trueorfalse(default value))-
For databases that don’t support local tables, but just global ones, this configuration property allows you to DROP the global tables used for multi-table bulk HQL operations when the
SessionFactoryor theEntityManagerFactoryis closed. hibernate.hql.bulk_id_strategy.persistent.drop_tables(e.g.trueorfalse(default value))-
This configuration property is used by the
PersistentTableBulkIdStrategy, that mimics temporary tables for databases which do not support temporary tables. It follows a pattern similar to the ANSI SQL definition of global temporary table using a "session id" column to segment rows from the various sessions.This configuration property allows you to DROP the tables used for multi-table bulk HQL operations when the
SessionFactoryor theEntityManagerFactoryis closed. hibernate.hql.bulk_id_strategy.persistent.schema(e.g. Database schema name. By default, thehibernate.default_schemais used.)-
This configuration property is used by the
PersistentTableBulkIdStrategy, that mimics temporary tables for databases which do not support temporary tables. It follows a pattern similar to the ANSI SQL definition of global temporary table using a "session id" column to segment rows from the various sessions.This configuration property defines the database schema used for storing the temporary tables used for bulk HQL operations.
hibernate.hql.bulk_id_strategy.persistent.catalog(e.g. Database catalog name. By default, thehibernate.default_catalogis used.)-
This configuration property is used by the
PersistentTableBulkIdStrategy, that mimics temporary tables for databases which do not support temporary tables. It follows a pattern similar to the ANSI SQL definition of global temporary table using a "session id" column to segment rows from the various sessions.This configuration property defines the database catalog used for storing the temporary tables used for bulk HQL operations.
hibernate.legacy_limit_handler(e.g.trueorfalse(default value))-
Setting which indicates whether or not to use
org.hibernate.dialect.pagination.LimitHandlerimplementations that sacrifices performance optimizations to allow legacy 4.x limit behavior.Legacy 4.x behavior favored performing pagination in-memory by avoiding the use of the offset value, which is overall poor performance. In 5.x, the limit handler behavior favors performance, thus, if the dialect doesn’t support offsets, an exception is thrown instead.
hibernate.query.conventional_java_constants(e.g.true(default value) orfalse)-
Setting which indicates whether or not Java constant follow the Java Naming conventions.
Default is
true. Existing applications may want to disable this (set itfalse) if non-conventional Java constants are used. However, there is a significant performance overhead for using non-conventional Java constants since Hibernate cannot determine if aliases should be treated as Java constants or not.Check out HHH-4959 for more details.
Batching properties
hibernate.jdbc.batch_size(e.g. 5)-
Maximum JDBC batch size. A nonzero value enables batch updates.
hibernate.order_inserts(e.g.trueorfalse(default value))-
Forces Hibernate to order SQL inserts by the primary key value of the items being inserted. This preserves batching when using cascading.
hibernate.order_updates(e.g.trueorfalse(default value))-
Forces Hibernate to order SQL updates by the primary key value of the items being updated. This preserves batching when using cascading and reduces the likelihood of transaction deadlocks in highly-concurrent systems.
hibernate.jdbc.batch_versioned_data(e.g.true(default value) orfalse)-
Should versioned entities be included in batching?
Set this property to
trueif your JDBC driver returns correct row counts from executeBatch(). This option is usually safe, but is disabled by default. If enabled, Hibernate uses batched DML for automatically versioned data. hibernate.batch_fetch_style(e.g.LEGACY(default value))-
Names the
BatchFetchStyleto use.Can specify either the
BatchFetchStylename (insensitively), or aBatchFetchStyleinstance.LEGACY}is the default value. hibernate.jdbc.batch.builder(e.g. The fully qualified name of anBatchBuilderimplementation class type or an actual object instance)-
Names the
BatchBuilderimplementation to use.
Fetching properties
hibernate.max_fetch_depth(e.g. A value between0and3)-
Sets a maximum depth for the outer join fetch tree for single-ended associations. A single-ended association is a one-to-one or many-to-one assocation. A value of
0disables default outer join fetching. hibernate.default_batch_fetch_size(e.g.4,8, or16)-
Default size for Hibernate Batch fetching of associations (lazily fetched associations can be fetched in batches to prevent N+1 query problems).
hibernate.jdbc.fetch_size(e.g.0or an integer)-
A non-zero value determines the JDBC fetch size, by calling
Statement.setFetchSize(). hibernate.jdbc.use_scrollable_resultset(e.g.trueorfalse)-
Enables Hibernate to use JDBC2 scrollable resultsets. This property is only relevant for user-supplied JDBC connections. Otherwise, Hibernate uses connection metadata.
hibernate.jdbc.use_streams_for_binary(e.g.trueorfalse(default value))-
Use streams when writing or reading
binaryorserializabletypes to or from JDBC. This is a system-level property. hibernate.jdbc.use_get_generated_keys(e.g.trueorfalse)-
Allows Hibernate to use JDBC3
PreparedStatement.getGeneratedKeys()to retrieve natively-generated keys after insert. You need the JDBC3+ driver and JRE1.4+. Disable this property if your driver has problems with the Hibernate identifier generators. By default, it tries to detect the driver capabilities from connection metadata. hibernate.jdbc.wrap_result_sets(e.g.trueorfalse(default value))-
Enable wrapping of JDBC result sets in order to speed up column name lookups for broken JDBC drivers.
hibernate.enable_lazy_load_no_trans(e.g.trueorfalse(default value))-
Initialize Lazy Proxies or Collections outside a given Transactional Persistence Context.
Although enabling this configuration can make
LazyInitializationExceptiongo away, it’s better to use a fetch plan that guarantees that all properties are properly initialised before the Session is closed.In reality, you shouldn’t probably enable this setting anyway.
Statement logging and statistics
SQL statement logging
hibernate.show_sql(e.g.trueorfalse(default value))-
Write all SQL statements to the console. This is an alternative to setting the log category
org.hibernate.SQLto debug. hibernate.format_sql(e.g.trueorfalse(default value))-
Pretty-print the SQL in the log and console.
hibernate.use_sql_comments(e.g.trueorfalse(default value))-
If true, Hibernate generates comments inside the SQL, for easier debugging.
Statistics settings
hibernate.generate_statistics(e.g.trueorfalse)-
Causes Hibernate to collect statistics for performance tuning.
hibernate.stats.factory(e.g. the fully qualified name of anStatisticsFactoryimplementation or an actual instance)-
The
StatisticsFactoryallow you to customize how the Hibernate Statistics are being collected. hibernate.session.events.log(e.g.trueorfalse)-
A setting to control whether the
org.hibernate.engine.internal.StatisticalLoggingSessionEventListeneris enabled on allSessions(unless explicitly disabled for a givenSession).The default value of this setting is determined by the value for
hibernate.generate_statistics, meaning that if statistics are enabled, then logging of Session metrics is enabled by default too.
Cache Properties
hibernate.cache.region.factory_class(e.g.org.hibernate.cache.infinispan.InfinispanRegionFactory)-
The fully-qualified name of the
RegionFactoryimplementation class. hibernate.cache.default_cache_concurrency_strategy-
Setting used to give the name of the default
CacheConcurrencyStrategyto use when either@javax.persistence.Cacheableor@org.hibernate.annotations.Cache.@org.hibernate.annotations.Cacheis used to override the global setting. hibernate.cache.use_minimal_puts(e.g.true(default value) orfalse)-
Optimizes second-level cache operation to minimize writes, at the cost of more frequent reads. This is most useful for clustered caches and is enabled by default for clustered cache implementations.
hibernate.cache.use_query_cache(e.g.trueorfalse(default value))-
Enables the query cache. You still need to set individual queries to be cachable.
hibernate.cache.use_second_level_cache(e.g.true(default value) orfalse)-
Enable/disable the second level cache, which is enabled by default, although the default
RegionFactorisNoCachingRegionFactory(meaning there is no actual caching implementation). hibernate.cache.query_cache_factory(e.g. Fully-qualified classname)-
A custom
QueryCacheFactoryinterface. The default is the built-inStandardQueryCacheFactory. hibernate.cache.region_prefix(e.g. A string)-
A prefix for second-level cache region names.
hibernate.cache.use_structured_entries(e.g.trueorfalse(default value))-
Forces Hibernate to store data in the second-level cache in a more human-readable format.
hibernate.cache.auto_evict_collection_cache(e.g.trueorfalse(default: false))-
Enables the automatic eviction of a bi-directional association’s collection cache when an element in the
ManyToOnecollection is added/updated/removed without properly managing the change on theOneToManyside. hibernate.cache.use_reference_entries(e.g.trueorfalse)-
Optimizes second-level cache operation to store immutable entities (aka "reference") which do not have associations into cache directly, this case, lots of disasseble and deep copy operations can be avoid. Default value of this property is
false. hibernate.ejb.classcache(e.g.hibernate.ejb.classcache.org.hibernate.ejb.test.Item=read-write)-
Sets the associated entity class cache concurrency strategy for the designated region. Caching configuration should follow the following pattern
hibernate.ejb.classcache.<fully.qualified.Classname>usage[, region] where usage is the cache strategy used and region the cache region name. hibernate.ejb.collectioncache(e.g.hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors=read-write, RegionName)-
Sets the associated collection cache concurrency strategy for the designated region. Caching configuration should follow the following pattern
hibernate.ejb.collectioncache.<fully.qualified.Classname>.<role>usage[, region] where usage is the cache strategy used and region the cache region name
Infinispan properties
hibernate.cache.infinispan.cfg(e.g.org/hibernate/cache/infinispan/builder/infinispan-configs.xml)-
Classpath or filesystem resource containing the Infinispan configuration settings.
hibernate.cache.infinispan.statistics-
Property name that controls whether Infinispan statistics are enabled. The property value is expected to be a boolean true or false, and it overrides statistic configuration in base Infinispan configuration, if provided.
hibernate.cache.infinispan.use_synchronization-
Deprecated setting because Infinispan is designed to always register a
SynchronizationforTRANSACTIONALcaches. hibernate.cache.infinispan.cachemanager(e.g. There is no default value, the user must specify the property.)-
Specifies the JNDI name under which the
EmbeddedCacheManageris bound.
Transactions properties
hibernate.transaction.jta.platform(e.g.JBossAS,BitronixJtaPlatform)-
Names the
JtaPlatformimplementation to use for integrating with JTA systems. Can reference either aJtaPlatforminstance or the name of theJtaPlatformimplementation class hibernate.jta.prefer_user_transaction(e.g.trueorfalse(default value))-
Should we prefer using the
org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform#retrieveUserTransactionover usingorg.hibernate.engine.transaction.jta.platform.spi.JtaPlatform#retrieveTransactionManager hibernate.transaction.jta.platform_resolver-
Names the
JtaPlatformResolverimplementation to use. hibernate.jta.cacheTransactionManager(e.g.true(default value) orfalse)-
A configuration value key used to indicate that it is safe to cache.
hibernate.jta.cacheUserTransaction(e.g.trueorfalse(default value))-
A configuration value key used to indicate that it is safe to cache.
hibernate.transaction.flush_before_completion(e.g.trueorfalse(default value))-
Causes the session be flushed during the before completion phase of the transaction. If possible, use built-in and automatic session context management instead.
hibernate.transaction.auto_close_session(e.g.trueorfalse(default value))-
Causes the session to be closed during the after completion phase of the transaction. If possible, use built-in and automatic session context management instead.
hibernate.transaction.coordinator_class-
Names the implementation of
TransactionCoordinatorBuilderto use for creatingTransactionCoordinatorinstances.Can be a`TransactionCoordinatorBuilder` instance,
TransactionCoordinatorBuilderimplementationClassreference, aTransactionCoordinatorBuilderimplementation class name (fully-qualified name) or a short name.The following short names are defined for this setting:
jdbc-
Manages transactions via calls to
java.sql.Connection(default for non-JPA applications) jta-
Manages transactions via JTA. See Java EE bootstrapping
If a JPA application does not provide a setting for
hibernate.transaction.coordinator_class, Hibernate will automatically build the proper transaction coordinator based on the transaction type for the persistence unit.If a non-JPA application does not provide a setting for
hibernate.transaction.coordinator_class, Hibernate will usejdbcas the default. This default will cause problems if the application actually uses JTA-based transactions. A non-JPA application that uses JTA-based transactions should explicitly sethibernate.transaction.coordinator_class=jtaor provide a customTransactionCoordinatorBuilderthat builds aTransactionCoordinatorthat properly coordinates with JTA-based transactions.
hibernate.jta.track_by_thread(e.g.true(default value) orfalse)-
A transaction can be rolled back by another thread ("tracking by thread") and not the original application. Examples of this include a JTA transaction timeout handled by a background reaper thread.
The ability to handle this situation requires checking the Thread ID every time Session is called, so enabling this can certainly have a performance impact.
hibernate.transaction.factory_class-
This is a legacy setting that’s been deprecated and you should use the
hibernate.transaction.jta.platforminstead.
Multi-tenancy settings
hibernate.multiTenancy(e.g.NONE(default value),SCHEMA,DATABASE, andDISCRIMINATOR(not implemented yet))-
The multi-tenancy strategy in use.
hibernate.multi_tenant_connection_provider(e.g.trueorfalse(default value))-
Names a
MultiTenantConnectionProviderimplementation to use. AsMultiTenantConnectionProvideris also a service, can be configured directly through theStandardServiceRegistryBuilder. hibernate.tenant_identifier_resolver-
Names a
CurrentTenantIdentifierResolverimplementation to resolve the resolve the current tenant identifier so that callingSessionFactory#openSession()would get aSessionthat’s connected to the right tenant.Can be a
CurrentTenantIdentifierResolverinstance,CurrentTenantIdentifierResolverimplementationClassobject reference or aCurrentTenantIdentifierResolverimplementation class name. hibernate.multi_tenant.datasource.identifier_for_any(e.g.trueorfalse(default value))-
When the
hibernate.connection.datasourceproperty value is resolved to ajavax.naming.Contextobject, this configuration property defines the JNDI name used to locate theDataSourceused for fetching the initialConnectionwhich is used to access to the database metadata of the underlying database(s) (in situations where we do not have a tenant id, like startup processing).
Automatic schema generation
hibernate.hbm2ddl.auto(e.g.none(default value),create-only,drop,create,create-drop,validate, andupdate)-
Setting to perform
SchemaManagementToolactions automatically as part of theSessionFactorylifecycle. Valid options are defined by theexternalHbm2ddlNamevalue of theActionenum:none-
No action will be performed.
create-only-
Database creation will be generated.
drop-
Database dropping will be generated.
create-
Database dropping will be generated followed by database creation.
create-drop-
Drop the schema and recreate it on SessionFactory startup. Additionally, drop the schema on SessionFactory shutdown.
validate-
Validate the database schema
update-
Update the database schema
javax.persistence.schema-generation.database.action(e.g.none(default value),create-only,drop,create,create-drop,validate, andupdate)-
Setting to perform
SchemaManagementToolactions automatically as part of theSessionFactorylifecycle. Valid options are defined by theexternalJpaNamevalue of theActionenum:none-
No action will be performed.
create-
Database creation will be generated.
drop-
Database dropping will be generated.
drop-and-create-
Database dropping will be generated followed by database creation.
javax.persistence.schema-generation.scripts.action(e.g.none(default value),create-only,drop,create,create-drop,validate, andupdate)-
Setting to perform
SchemaManagementToolactions writing the commands into a DDL script file. Valid options are defined by theexternalJpaNamevalue of theActionenum:none-
No action will be performed.
create-
Database creation will be generated.
drop-
Database dropping will be generated.
drop-and-create-
Database dropping will be generated followed by database creation.
javax.persistence.schema-generation-connection-
Allows passing a specific
java.sql.Connectioninstance to be used bySchemaManagementTool javax.persistence.database-product-name-
Specifies the name of the database provider in cases where a Connection to the underlying database is not available (aka, mainly in generating scripts). In such cases, a value for this setting must be specified.
The value of this setting is expected to match the value returned by
java.sql.DatabaseMetaData#getDatabaseProductName()for the target database.Additionally, specifying
javax.persistence.database-major-versionand/orjavax.persistence.database-minor-versionmay be required to understand exactly how to generate the required schema commands. javax.persistence.database-major-version-
Specifies the major version of the underlying database, as would be returned by
java.sql.DatabaseMetaData#getDatabaseMajorVersionfor the target database.This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where
javax.persistence.database-product-namedoes not provide enough distinction. javax.persistence.database-minor-version-
Specifies the minor version of the underlying database, as would be returned by
java.sql.DatabaseMetaData#getDatabaseMinorVersionfor the target database.This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where
javax.persistence.database-product-nameandjavax.persistence.database-major-versiondoes not provide enough distinction. javax.persistence.schema-generation.create-source-
Specifies whether schema generation commands for schema creation are to be determine based on object/relational mapping metadata, DDL scripts, or a combination of the two. See
SourceTypefor valid set of values.If no value is specified, a default is assumed as follows:
-
if source scripts are specified (per
javax.persistence.schema-generation.create-script-source), thenscriptsis assumed -
otherwise,
metadatais assumed
-
javax.persistence.schema-generation.drop-source-
Specifies whether schema generation commands for schema dropping are to be determine based on object/relational mapping metadata, DDL scripts, or a combination of the two. See
SourceTypefor valid set of values.If no value is specified, a default is assumed as follows:
-
if source scripts are specified (per
javax.persistence.schema-generation.create-script-source), thenscriptsis assumed -
otherwise,
metadatais assumed
-
javax.persistence.schema-generation.create-script-source-
Specifies the
createscript file as either ajava.io.Readerconfigured for reading of the DDL script file or a string designating a filejava.net.URLfor the DDL script.Hibernate historically also accepted
hibernate.hbm2ddl.import_filesfor a similar purpose, butjavax.persistence.schema-generation.create-script-sourceshould be preferred overhibernate.hbm2ddl.import_files. javax.persistence.schema-generation.drop-script-source-
Specifies the
dropscript file as either ajava.io.Readerconfigured for reading of the DDL script file or a string designating a filejava.net.URLfor the DDL script. javax.persistence.schema-generation.scripts.create-target-
For cases where the
javax.persistence.schema-generation.scripts.actionvalue indicates that schema creation commands should be written to DDL script file,javax.persistence.schema-generation.scripts.create-targetspecifies either ajava.io.Writerconfigured for output of the DDL script or a string specifying the file URL for the DDL script. javax.persistence.schema-generation.scripts.drop-target-
For cases where the
javax.persistence.schema-generation.scripts.actionvalue indicates that schema dropping commands should be written to DDL script file,javax.persistence.schema-generation.scripts.drop-targetspecifies either ajava.io.Writerconfigured for output of the DDL script or a string specifying the file URL for the DDL script. javax.persistence.hibernate.hbm2ddl.import_files(e.g.import.sql(default value))-
Comma-separated names of the optional files containing SQL DML statements executed during the
SessionFactorycreation. File order matters, the statements of a give file are executed before the statements of the following one.These statements are only executed if the schema is created, meaning that
hibernate.hbm2ddl.autois set tocreate,create-drop, orupdate.javax.persistence.schema-generation.create-script-source/javax.persistence.schema-generation.drop-script-sourceshould be preferred. javax.persistence.sql-load-script-source-
JPA variant of
hibernate.hbm2ddl.import_files. Specifies ajava.io.Readerconfigured for reading of the SQL load script or a string designating the filejava.net.URLfor the SQL load script. A "SQL load script" is a script that performs some database initialization (INSERT, etc). hibernate.hbm2ddl.import_files_sql_extractor-
Reference to the
ImportSqlCommandExtractorimplementation class to use for parsing source/import files as defined byjavax.persistence.schema-generation.create-script-source,javax.persistence.schema-generation.drop-script-sourceorhibernate.hbm2ddl.import_files.Reference may refer to an instance, a Class implementing
ImportSqlCommandExtractorof the fully-qualified name of theImportSqlCommandExtractorimplementation. If the fully-qualified name is given, the implementation must provide a no-arg constructor.The default value is
SingleLineSqlCommandExtractor. hibernate.hbm2dll.create_namespaces(e.g.trueorfalse(default value))-
Specifies whether to automatically create also the database schema/catalog.
javax.persistence.create-database-schemas(e.g.trueorfalse(default value))-
The JPA variant of
hibernate.hbm2dll.create_namespaces. Specifies whether the persistence provider is to create the database schema(s) in addition to creating database objects (tables, sequences, constraints, etc). The value of this boolean property should be set totrueif the persistence provider is to create schemas in the database or to generate DDL that contains "CREATE SCHEMA" commands.If this property is not supplied (or is explicitly
false), the provider should not attempt to create database schemas. hibernate.hbm2ddl.schema_filter_provider-
Used to specify the
SchemaFilterProviderto be used bycreate,drop,migrate, andvalidateoperations on the database schema.SchemaFilterProviderprovides filters that can be used to limit the scope of these operations to specific namespaces, tables and sequences. All objects are included by default. hibernate.hbm2ddl.jdbc_metadata_extraction_strategy(e.g.grouped(default value) orindividually)-
Setting to choose the strategy used to access the JDBC Metadata. Valid options are defined by the
strategyvalue of theJdbcMetadaAccessStrategyenum:grouped-
SchemaMigratorandSchemaValidatorexecute a singlejava.sql.DatabaseMetaData#getTables(String, String, String, String[])call to retrieve all the database table in order to determine if all thejavax.persistence.Entityhave a corresponding mapped database tables.This strategy may requirehibernate.default_schemaand/orhibernate.default_catalogto be provided. individually-
SchemaMigratorandSchemaValidatorexecute onejava.sql.DatabaseMetaData#getTables(String, String, String, String[])call for eachjavax.persistence.Entityin order to determine if a corresponding database table exists.
hibernate.hbm2ddl.delimiter(e.g.;)-
Identifies the delimiter to use to separate schema management statements in script outputs.
hibernate.schema_management_tool(e.g. A schema name)-
Used to specify the
SchemaManagementToolto use for performing schema management. The default is to useHibernateSchemaManagementTool hibernate.synonyms(e.g.trueorfalse(default value))-
If enabled, allows schema update and validation to support synonyms. Due to the possibility that this would return duplicate tables (especially in Oracle), this is disabled by default.
hibernate.hbm2dll.extra_physical_table_types(e.g.BASE TABLE)-
Identifies a comma-separated list of values to specify extra table types, other than the default
TABLEvalue, to recognize as defining a physical table by schema update, creation and validation. hibernate.schema_update.unique_constraint_strategy(e.g.DROP_RECREATE_QUIETLY,RECREATE_QUIETLY,SKIP)-
Unique columns and unique keys both use unique constraints in most dialects.
SchemaUpdateneeds to create these constraints, but DBs support for finding existing constraints is extremely inconsistent. Further, non-explicitly-named unique constraints use randomly generated characters.Therefore, the
UniqueConstraintSchemaUpdateStrategyoffers the following options:DROP_RECREATE_QUIETLY-
Default option. Attempt to drop, then (re-)create each unique constraint. Ignore any exceptions being thrown.
RECREATE_QUIETLY-
Attempts to (re-)create unique constraints, ignoring exceptions thrown if the constraint already existed
SKIP-
Does not attempt to create unique constraints on a schema update.
hibernate.hbm2ddl.charset_name(e.g.Charset.defaultCharset())-
Defines the charset (encoding) used for all input/output schema generation resources. By default, Hibernate uses the default charset given by
Charset.defaultCharset(). This configuration property allows you to override the default JVM setting so that you can specify which encoding is used when reading and writing schema generation resources (e.g. File, URL). hibernate.hbm2ddl.halt_on_error(e.g.trueorfalse(default value))-
Whether the schema migration tool should halt on error, therefore terminating the bootstrap process. By default, the
EntityManagerFactoryorSessionFactoryare created even if the schema migration throws exceptions. To prevent this default behavior, set this property value totrue.
Exception handling
hibernate.jdbc.sql_exception_converter(e.g. Fully-qualified name of class implementingSQLExceptionConverter)-
The
SQLExceptionConverterto use for convertingSQLExceptionsto Hibernate’sJDBCExceptionhierarchy. The default is to use the configuredDialect's preferredSQLExceptionConverter.
Session events
hibernate.session.events.auto-
Fully qualified class name implementing the
SessionEventListenerinterface. hibernate.session_factory.interceptororhibernate.ejb.interceptor(e.g.org.hibernate.EmptyInterceptor(default value))-
Names a
Interceptorimplementation to be applied to everySessioncreated by the currentorg.hibernate.SessionFactoryCan reference:
-
Interceptorinstance -
InterceptorimplementationClassobject reference -
Interceptorimplementation class name
-
hibernate.ejb.interceptor.session_scoped(e.g. fully-qualified class name or class reference)-
An optional Hibernate interceptor.
The interceptor instance is specific to a given Session instance (and hence is not thread-safe) has to implement
org.hibernate.Interceptorand have a no-arg constructor.This property can not be combined with
hibernate.ejb.interceptor. hibernate.ejb.session_factory_observer(e.g. fully-qualified class name or class reference)-
Specifies a
SessionFactoryObserverto be applied to the SessionFactory. The class must have a no-arg constructor. hibernate.ejb.event(e.g.hibernate.ejb.event.pre-load=com.acme.SecurityListener,com.acme.AuditListener)-
Event listener list for a given event type. The list of event listeners is a comma separated fully qualified class name list.
JMX settings
hibernate.jmx.enabled(e.g.trueorfalse(default value))-
Enable JMX.
hibernate.jmx.usePlatformServer(e.g.trueorfalse(default value))-
Uses the platform MBeanServer as returned by
ManagementFactory#getPlatformMBeanServer(). hibernate.jmx.agentId-
The agent identifier of the associated
MBeanServer. hibernate.jmx.defaultDomain-
The domain name of the associated
MBeanServer. hibernate.jmx.sessionFactoryName-
The
SessionFactoryname appended to the object name the Manageable Bean is registered with. If null, thehibernate.session_factory_nameconfiguration value is used. org.hibernate.core-
The default object domain appended to the object name the Manageable Bean is registered with.
JACC settings
hibernate.jacc.enabled(e.g.trueorfalse(default value))-
Is JACC enabled?
hibernate.jacc(e.g.hibernate.jacc.allowed.org.jboss.ejb3.test.jacc.AllEntity)-
The property name defines the role (e.g.
allowed) and the entity class name (e.g.org.jboss.ejb3.test.jacc.AllEntity), while the property value defines the authorized actions (e.g.insert,update,read). hibernate.jacc_context_id-
A String identifying the policy context whose PolicyConfiguration interface is to be returned. The value passed to this parameter must not be null.
ClassLoaders properties
hibernate.classLoaders-
Used to define a
java.util.Collection<ClassLoader>or theClassLoaderinstance Hibernate should use for class-loading and resource-lookups. hibernate.classLoader.application-
Names the
ClassLoaderused to load user application classes. hibernate.classLoader.resources-
Names the
ClassLoaderHibernate should use to perform resource loading. hibernate.classLoader.hibernate-
Names the
ClassLoaderresponsible for loading Hibernate classes. By default this is theClassLoaderthat loaded this class. hibernate.classLoader.environment-
Names the
ClassLoaderused when Hibernate is unable to locates classes on thehibernate.classLoader.applicationorhibernate.classLoader.hibernate.
Bootstrap properties
hibernate.integrator_provider(e.g. The fully qualified name of anIntegratorProvider)-
Used to define a list of
Integratorwhich are used during bootstrap process to integrate various services. hibernate.strategy_registration_provider(e.g. The fully qualified name of anStrategyRegistrationProviderList)-
Used to define a list of
StrategyRegistrationProviderwhich are used during bootstrap process to provide registrations of strategy selector(s). hibernate.type_contributors(e.g. The fully qualified name of anTypeContributorList)-
Used to define a list of
TypeContributorwhich are used during bootstrap process to contribute types. hibernate.persister.resolver(e.g. The fully qualified name of aPersisterClassResolveror aPersisterClassResolverinstance)-
Used to define an implementation of the
PersisterClassResolverinterface which can be used to customize how an entity or a collection is being persisted. hibernate.persister.factory(e.g. The fully qualified name of aPersisterFactoryor aPersisterFactoryinstance)-
Like a
PersisterClassResolver, thePersisterFactorycan be used to customize how an entity or a collection are being persisted. hibernate.service.allow_crawling(e.g.true(default value) orfalse)-
Crawl all available service bindings for an alternate registration of a given Hibernate
Service. hibernate.metadata_builder_contributor(e.g. The instance, the class or the fully qualified class name of anMetadataBuilderContributor)-
Used to define a instance, the class or the fully qualified class name of an
MetadataBuilderContributorwhich can be used to configure theMetadataBuilderwhen bootstrapping via the JPAEntityManagerFactory.
Miscellaneous properties
hibernate.dialect_resolvers-
Names any additional
DialectResolverimplementations to register with the standardDialectFactory hibernate.session_factory_name(e.g. A JNDI name)-
Setting used to name the Hibernate
SessionFactory. Naming theSessionFactoryallows for it to be properly serialized across JVMs as long as the same name is used on each JVM.If
hibernate.session_factory_name_is_jndiis set totrue, this is also the name under which theSessionFactoryis bound into JNDI on startup and from which it can be obtained from JNDI. hibernate.session_factory_name_is_jndi(e.g.true(default value) orfalse)-
Does the value defined by
hibernate.session_factory_namerepresent a JNDI namespace into which theorg.hibernate.SessionFactoryshould be bound and made accessible?Defaults to
truefor backwards compatibility. Set this tofalseif naming a SessionFactory is needed for serialization purposes, but no writable JNDI context exists in the runtime environment or if the user simply does not want JNDI to be used. hibernate.ejb.entitymanager_factory_name(e.g. By default, the persistence unit name is used, otherwise a randomly generated UUID)-
Internally, Hibernate keeps track of all
EntityManagerFactoryinstances using theEntityManagerFactoryRegistry. The name is used as a key to identify a givenEntityManagerFactoryreference. hibernate.ejb.cfgfile(e.g.hibernate.cfg.xml(default value))-
XML configuration file to use to configure Hibernate.
hibernate.ejb.discard_pc_on_close(e.g.trueorfalse(default value))-
If true, the persistence context will be discarded (think
clear()when the method is called. Otherwise, the persistence context will stay alive till the transaction completion: all objects will remain managed, and any change will be synchronized with the database (default to false, ie wait for transaction completion). hibernate.ejb.metamodel.population(e.g.enabledordisabled, orignoreUnsupported(default value))-
Setting that indicates whether to build the JPA types.
Accepts three values:
- enabled
-
Do the build
- disabled
-
Do not do the build
- ignoreUnsupported
-
Do the build, but ignore any non-JPA features that would otherwise result in a failure (e.g.
@Anyannotation).
hibernate.jpa.static_metamodel.population(e.g.enabledordisabled, orskipUnsupported(default value))-
Setting that controls whether we seek out JPA static metamodel classes and populate them.
Accepts three values:
- enabled
-
Do the population
- disabled
-
Do not do the population
- skipUnsupported
-
Do the population, but ignore any non-JPA features that would otherwise result in the population failing (e.g.
@Anyannotation).
hibernate.delay_cdi_access(e.g.trueorfalse(default value))-
Defines delayed access to CDI
BeanManager. Starting in 5.1 the preferred means for CDI bootstrapping is throughExtendedBeanManager. hibernate.allow_update_outside_transaction(e.g.trueorfalse(default value))-
Setting that allows to perform update operations outside of a transaction boundary.
Accepts two values:
- true
-
allows to flush an update out of a transaction
- false
-
does not allow
hibernate.collection_join_subquery(e.g.true(default value) orfalse)-
Setting which indicates whether or not the new JOINS over collection tables should be rewritten to subqueries.
hibernate.allow_refresh_detached_entity(e.g.true(default value when using Hibernate native bootstrapping) orfalse(default value when using JPA bootstrapping))-
Setting that allows to call
javax.persistence.EntityManager#refresh(entity)orSession#refresh(entity)on a detached instance even when theorg.hibernate.Sessionis obtained from a JPAjavax.persistence.EntityManager. hibernate.event.merge.entity_copy_observer(e.g.disallow(default value),allow,log(testing purpose only) or fully-qualified class name)-
Setting that specifies how Hibernate will respond when multiple representations of the same persistent entity ("entity copy") is detected while merging.
The possible values are:
- disallow (the default)
-
throws
IllegalStateExceptionif an entity copy is detected - allow
-
performs the merge operation on each entity copy that is detected
- log
-
(provided for testing only) performs the merge operation on each entity copy that is detected and logs information about the entity copies. This setting requires DEBUG logging be enabled for
EntityCopyAllowedLoggedObserver.In addition, the application may customize the behavior by providing an implementation of
EntityCopyObserverand settinghibernate.event.merge.entity_copy_observerto the class name. When this property is set toalloworlog, Hibernate will merge each entity copy detected while cascading the merge operation. In the process of merging each entity copy, Hibernate will cascade the merge operation from each entity copy to its associations withcascade=CascadeType.MERGEorCascadeType.ALL. The entity state resulting from merging an entity copy will be overwritten when another entity copy is merged.For more details, check out the Merge gotchas section.
Envers properties
hibernate.envers.autoRegisterListeners(e.g.true(default value) orfalse)-
When set to
false, the Envers entity listeners are no longer auto-registered, so you need to register them manually during the bootstrap process. hibernate.integration.envers.enabled(e.g.true(default value) orfalse)-
Enable or disable the Hibernate Envers
Serviceintegration. hibernate.listeners.envers.autoRegister-
Legacy setting. Use
hibernate.envers.autoRegisterListenersorhibernate.integration.envers.enabledinstead.
Spatial properties
hibernate.integration.spatial.enabled(e.g.true(default value) orfalse)-
Enable or disable the Hibernate Spatial
Serviceintegration. hibernate.spatial.connection_finder(e.g.org.geolatte.geom.codec.db.oracle.DefaultConnectionFinder)-
Define the fully-qualified name of class implementing the
org.geolatte.geom.codec.db.oracle.ConnectionFinderinterface.
Internal properties
The following configuration properties are used internally, and you shouldn’t probably have to configured them in your application.
hibernate.enable_specj_proprietary_syntax(e.g.trueorfalse(default value))-
Enable or disable the SpecJ proprietary mapping syntax which differs from JPA specification. Used during performance testing only.
hibernate.temp.use_jdbc_metadata_defaults(e.g.true(default value) orfalse)-
This setting is used to control whether we should consult the JDBC metadata to determine certain Settings default values when the database may not be available (mainly in tools usage).
hibernate.connection_provider.injection_data(e.g.java.util.Map)-
Connection provider settings to be injected in the currently configured connection provider.
hibernate.jandex_index(e.g.org.jboss.jandex.Index)-
Names a Jandex
org.jboss.jandex.Indexinstance to use.