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.Class
reference of the strategy implementation to use - strategy Class name
-
The class name (
java.lang.String
) of the strategy implementation to use
General Configuration
Property |
Example |
Purpose |
|
|
The classname of a Hibernate In most cases Hibernate can choose the correct |
|
|
Supply a custom strategy for the scoping of the current The definition of what exactly current means is controlled by the Note that for backwards compatibility, if a |
Database connection properties
Property |
Example |
Purpose |
|
|
Names the JDBC |
|
|
Names the JDBC connection URL. |
|
Names the JDBC connection user name. |
|
|
Names the JDBC connection password. |
|
|
|
Names the JDBC connection transaction isolation level. |
|
|
Names the JDBC connection autocommit mode. |
|
20 |
Maximum number of connections for the built-in Hibernate connection pool. |
|
Either a For JNDI names, ses also |
|
|
Names a prefix used to define arbitrary JDBC connection properties. These properties are passed along to the JDBC provider when creating a connection. |
|
|
|
Names the Can reference:
The term |
|
Names the JNDI |
|
|
java:global/jdbc/default |
Names the JNDI provider/connection url. |
|
Names a prefix used to define arbitrary JNDI These properties are passed along to |
|
|
|
Specifies how Hibernate should acquire JDBC connections. The possible values are given by Should generally only configure this or |
|
|
Specifies how Hibernate should release JDBC connections. The possible values are given by the current transaction mode ( Should generally only configure this or |
c3p0 properties
Property |
Example |
Purpose |
|
1 |
Minimum size of C3P0 connection pool. Refers to c3p0 |
|
5 |
Maximum size of C3P0 connection pool. Refers to c3p0 |
|
30 |
Maximum idle time for C3P0 connection pool. Refers to c3p0 |
|
5 |
Maximum size of C3P0 statement cache. Refers to c3p0 |
|
2 |
Number of connections acquired at a time when there’s no connection available in the pool. Refers to c3p0 |
|
5 |
Idle time before a C3P0 pooled connection is validated. Refers to c3p0 |
|
A setting prefix used to indicate additional c3p0 properties that need to be passed to the underlying c3p0 connection pool. |
Mapping Properties
Property |
Example |
Purpose |
Table qualifying options |
||
|
A schema name |
Qualify unqualified table names with the given schema or tablespace in generated SQL. |
|
A catalog name |
Qualifies unqualified table names with the given catalog in generated SQL. A setting to control whether to |
Identifier options |
||
|
|
Setting which indicates whether or not the new Existing applications may want to disable this (set it |
|
|
If true, generated identifier properties are reset to default values when objects are deleted. |
|
|
When a generator specified an increment-size and an optimizer was not explicitly specified, which of the pooled optimizers should be preferred? |
Quoting options |
||
|
|
Should all database identifiers be quoted. |
|
|
Assuming |
|
|
Specifies whether to automatically quote any names that are deemed keywords. |
Discriminator options |
||
|
|
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. However, we want to make sure that legacy applications continue to work as well, which 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. |
|
|
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 See Hibernate Jira issue HHH-6911 for additional background info. |
Naming strategies |
||
|
|
Used to specify the
If this property happens to be empty, the fallback is to use |
|
|
Used to specify the |
Metadata scanning options |
||
|
Pass an implementation of Accepts either:
|
|
|
Pass Accepts either:
See information on |
|
|
|
Identifies a comma-separate list of values indicating the mapping types we should auto-detect during scanning. Allowable values include:
|
|
|
Used to specify the order in which metadata sources should be processed.
Value is a delimited-list whose elements are defined by Default is |
JDBC-related options |
||
|
|
Enable nationalized character support on all string / clob based attribute ( string, char, clob, text etc ). |
|
|
Should we not use contextual LOB creation (aka based on |
Bean Validation options |
||
|
|
Specify the |
|
|
Enable nullability checking. Raises an exception if a property marked as not-null is null. Default to |
Misc options |
||
|
|
Enable instantiation of composite/embeddable objects when all of its attribute values are 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. |
|
fully-qualified class name or an actual |
Setting to identify a |
|
|
Default |
Bytecode Enhancement Properties
Property |
Example |
Purpose |
|
|
Enable dirty tracking feature in runtime bytecode enhancement. |
|
|
Enable lazy loading feature in runtime bytecode enhancement. This way, even basic types (e.g. |
|
|
Enable association management feature in runtime bytecode enhancement which automatically synchronizes a bidirectional association when only one side is changed. |
|
|
The |
|
|
Should we use reflection optimization? The reflection optimizer implements the |
Query settings
Property |
Example |
Purpose |
|
|
The maximum number of entries including:
maintained by |
|
|
The maximum number of strong references associated with |
|
|
Defines precedence of null values in |
|
|
For entities which do not explicitly say, should we force discriminators into SQL selects? |
|
|
A comma-separated list of token substitutions to use when translating a Hibernate query to SQL. |
|
|
Chooses the HQL parser implementation. |
|
|
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 |
|
|
Should named queries be checked during startup? |
|
|
Setting which indicates whether or not Java constant follow the Java Naming conventions. Default is There is a significant performance improvement by setting With Check out HHH-4959 for more details. |
|
A fully-qualified class name, an instance, or a |
Provide a custom |
|
|
Global setting for whether This defines a global setting, which can then be controlled per parameter via Values are |
|
|
Enable fetching JDBC statement warning for logging. Default value is given by |
|
A fully-qualified class name, an instance, or a |
Names a Can reference
|
Batching properties
Property |
Example |
Purpose |
|
5 |
Maximum JDBC batch size. A nonzero value enables batch updates. |
|
|
Forces Hibernate to order SQL inserts by the primary key value of the items being inserted. This preserves batching when using cascading. |
|
|
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. |
|
|
Should versioned entities be included in batching? Set this property to |
|
|
Names the Can specify either the |
|
The fully qualified name of an |
Names the |
Fetching properties
Property |
Example |
Purpose |
|
A value between |
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 |
|
|
Default size for Hibernate Batch fetching of associations (lazily fetched associations can be fetched in batches to prevent N+1 query problems). |
|
|
A non-zero value determines the JDBC fetch size, by calling |
|
|
Enables Hibernate to use JDBC2 scrollable resultsets. This property is only relevant for user-supplied JDBC connections. Otherwise, Hibernate uses connection metadata. |
|
|
Use streams when writing or reading |
|
|
Allows Hibernate to use JDBC3 |
|
|
Enable wrapping of JDBC result sets in order to speed up column name lookups for broken JDBC drivers. |
|
|
Initialize Lazy Proxies or Collections outside a given Transactional Persistence Context. Although enabling this configuration can make In reality, you shouldn’t probably enable this setting anyway. |
Statement logging and statistics
Property |
Example |
Purpose |
SQL statement logging |
||
|
|
Write all SQL statements to the console. This is an alternative to setting the log category |
|
|
Pretty-print the SQL in the log and console. |
|
|
If true, Hibernate generates comments inside the SQL, for easier debugging. |
Statistics settings |
||
|
|
Causes Hibernate to collect statistics for performance tuning. |
|
|
A setting to control whether to |
Cache Properties
Property |
Example |
Purpose |
|
|
The fully-qualified name of the |
|
Setting used to give the name of the default |
|
|
|
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. |
|
|
Enables the query cache. You still need to set individual queries to be cachable. |
|
|
Enable/disable the second level cache, which is enabled by default, although the default |
|
Fully-qualified classname |
A custom |
|
A string |
A prefix for second-level cache region names. |
|
|
Forces Hibernate to store data in the second-level cache in a more human-readable format. |
|
|
Enables the automatic eviction of a bi-directional association’s collection cache when an element in the |
|
|
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 |
|
|
Sets the associated entity class cache concurrency strategy for the designated region. Caching configuration should follow the following pattern |
|
|
Sets the associated collection cache concurrency strategy for the designated region. Caching configuration should follow the following pattern |
Transactions properties
Property |
Example |
Purpose |
|
|
Names the |
|
|
Should we prefer using the |
|
Names the |
|
|
|
A configuration value key used to indicate that it is safe to cache. |
|
|
A configuration value key used to indicate that it is safe to cache. |
|
|
Causes the session be flushed during the before completion phase of the transaction. If possible, use built-in and automatic session context management instead. |
|
|
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. |
|
Names the implementation of Can be
The following short names are defined for this setting:
If a JPA application does not provide a setting for If a non-JPA application does not provide a setting for |
|
|
|
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. |
Multi-tenancy settings
Property |
Example |
Purpose |
|
|
The multi-tenancy strategy in use. |
|
|
Names a |
|
Names a Can be:
|
Automatic schema generation
Property |
Example |
Purpose |
|
|
Setting to perform
|
|
|
Setting to perform
|
|
|
Setting to perform
|
|
Allows passing a specific |
|
|
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 Additionally, specifying |
|
|
Specifies the major version of the underlying database, as would be returned by This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where |
|
|
Specifies the minor version of the underlying database, as would be returned by This value is used to help more precisely determine how to perform schema generation tasks for the underlying database in cases where |
|
|
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 If no value is specified, a default is assumed as follows:
|
|
|
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 If no value is specified, a default is assumed as follows:
|
|
|
Specifies the Hibernate historically also accepted |
|
|
Specifies the |
|
|
For cases where the |
|
|
For cases where the |
|
|
|
Comma-separated names of the optional files containing SQL DML statements executed during the These statements are only executed if the schema is created, meaning that |
|
JPA variant of |
|
|
Reference to the Reference may refer to an instance, a Class implementing The default value is |
|
|
|
Specifies whether to automatically create also the database schema/catalog. |
|
|
The JPA variant of |
|
Used to specify the |
|
|
|
Setting to choose the strategy used to access the JDBC Metadata.
Valid options are defined by the
|
|
|
Identifies the delimiter to use to separate schema management statements in script outputs. |
|
A schema name |
Used to specify the |
|
|
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. |
|
|
Identifies a comma-separated list of values to specify extra table types, other than the default |
|
|
Unique columns and unique keys both use unique constraints in most dialects.
Therefore, the
|
Exception handling
Property |
Example |
Purpose |
|
Fully-qualified name of class implementing |
The |
Session events
Property |
Example |
Purpose |
|
Fully qualified class name implementing the |
|
|
|
Names a Can reference:
|
|
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 This property can not be combined with |
|
fully-qualified class name or class reference |
Specifies a |
|
|
Event listener list for a given event type. The list of event listeners is a comma separated fully qualified class name list. |
JMX settings
Property |
Example |
Purpose |
|
|
Enable JMX. |
|
|
Uses the platform MBeanServer as returned by |
|
The agent identifier of the associated |
|
|
The domain name of the associated |
|
|
The |
|
`org.hibernate.core |
The default object domain appended to the object name the Manageable Bean is registered with. |
JACC settings
Property |
Example |
Purpose |
|
|
Is JACC enabled? |
|
|
The property name defines the role (e.g. |
|
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
Property |
Example |
Purpose |
|
Used to define a |
|
|
Names the |
|
|
Names the |
|
|
Names the |
|
|
Names the |
Miscellaneous properties
Property |
Example |
Purpose |
|
Names any additional |
|
|
A JNDI name |
Setting used to name the Hibernate If |
|
|
Does the value defined by Defaults to |
|
By default, the persistence unit name is used, otherwise a randomly generated UUID |
Internally, Hibernate keeps track of all |
|
|
XML configuration file to use to configure Hibernate. |
|
|
If true, the persistence context will be discarded (think |
|
|
Setting that controls whether we seek out JPA static metamodel classes and populate them. Accepts three values:
|
|
|
Defines delayed access to CDI |
|
|
Setting which indicates whether or not the new JOINS over collection tables should be rewritten to subqueries. |
|
|
Setting controls whether an entity’s "where" clause, mapped using |