Hibernate.orgCommunity Documentation
Table of Contents
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:
Certain built-in strategy implementations have a corresponding short name.
An instance of the strategy implementation to use can be specified
A java.lang.Class
reference of the strategy implementation to use can
be specified
The class name (java.lang.String
) of the strategy implementation to
use can be specified
hibernate.dialect | A fully-qualified classname |
The classname of a Hibernate
In most cases Hibernate can choose the correct |
hibernate.show_sql |
| Write all SQL statements to the console. This is an alternative to setting the log category org.hibernate.SQL to debug. |
hibernate.format_sql |
| Pretty-print the SQL in the log and console. |
hibernate.default_schema | A schema name | Qualify unqualified table names with the given schema or tablespace in generated SQL. |
hibernate.default_catalog | A catalog name | Qualifies unqualified table names with the given catalog in generated SQL. |
hibernate.session_factory_name | A JNDI name | The org.hibernate.SessionFactory is automatically bound to this name in JNDI
after it is created. |
hibernate.max_fetch_depth | A value between 0 and 3 | Sets a maximum depth for the outer join fetch tree for single-ended associations. A single-ended
assocation is a one-to-one or many-to-one assocation. A value of 0 disables default outer
join fetching. |
hibernate.default_batch_fetch_size |
| Default size for Hibernate batch fetching of associations. |
hibernate.default_entity_mode |
| Default mode for entity representation for all sessions opened from this
SessionFactory , defaults to pojo . |
hibernate.order_updates |
| Forces Hibernate to order SQL updates by the primary key value of the items being updated. This reduces the likelihood of transaction deadlocks in highly-concurrent systems. |
hibernate.order_by.default_null_ordering |
| Defines precedence of null values in ORDER BY clause. Defaults to
none which varies between RDBMS implementation. |
hibernate.generate_statistics |
| Causes Hibernate to collect statistics for performance tuning. |
hibernate.use_identifier_rollback |
| If true, generated identifier properties are reset to default values when objects are deleted. |
hibernate.use_sql_comments |
| If true, Hibernate generates comments inside the SQL, for easier debugging. |
Table A.1. JDBC properties
Property | Example | Purpose |
---|---|---|
hibernate.jdbc.fetch_size | 0 or an integer | A non-zero value determines the JDBC fetch size, by calling
Statement.setFetchSize() . |
hibernate.jdbc.batch_size | A value between | A non-zero value causes Hibernate to use JDBC2 batch updates. |
hibernate.jdbc.batch_versioned_data |
| Set this property to |
hibernate.jdbc.factory_class | The fully-qualified class name of the factory | Select a custom |
hibernate.jdbc.use_scrollable_resultset |
| 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 |
| Use streams when writing or reading binary or serializable types to or from JDBC. This is a system-level property. |
hibernate.jdbc.use_get_generated_keys |
| Allows Hibernate to use JDBC3 |
Table A.2. Cache Properties
Property | Example | Purpose |
---|---|---|
hibernate.cache.provider_class | Fully-qualified classname | The classname of a custom CacheProvider. |
hibernate.cache.use_minimal_puts |
| 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 |
| Enables the query cache. You still need to set individual queries to be cachable. |
hibernate.cache.use_second_level_cache |
| Completely disable the second level cache, which is enabled by default for classes which specify a <cache> mapping. |
hibernate.cache.query_cache_factory | Fully-qualified classname | A custom QueryCache interface. The default is the built-in
StandardQueryCache . |
hibernate.cache.region_prefix | A string | A prefix for second-level cache region names. |
hibernate.cache.use_structured_entries |
| Forces Hibernate to store data in the second-level cache in a more human-readable format. |
hibernate.cache.auto_evict_collection_cache |
| Enables the automatic eviction of a bi-directional association's collection cache when an element in the ManyToOne collection is added/updated/removed without properly managing the change on the OneToMany side. |
hibernate.cache.use_reference_entries |
| 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 .
|
Table A.3. Transactions properties
Property | Example | Purpose |
---|---|---|
hibernate.transaction.factory_class |
jdbc or |
Names the |
jta.UserTransaction | A JNDI name | The |
hibernate.transaction.manager_lookup_class | A fully-qualified classname | The classname of a |
hibernate.transaction.flush_before_completion |
| 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 |
| 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. |
Each of the properties in the following table are prefixed by hibernate.
. It has been removed
in the table to conserve space.
Table A.4. Miscellaneous properties
Property | Example | Purpose |
---|---|---|
current_session_context_class | One of | Supply a custom strategy for the scoping of the |
factory_class |
| Chooses the HQL parser implementation. |
query.substitutions |
| Map from tokens in Hibernate queries to SQL tokens, such as function or literal names. |
hbm2ddl.auto |
| Validates or exports schema DDL to the database when the SessionFactory is
created. With create-drop, the database schema is dropped when the
SessionFactory is closed explicitly. |
c3p0 connection pool properties
hibernate.c3p0.min_size
hibernate.c3p0.max_size
hibernate.c3p0.timeout
hibernate.c3p0.max_statements
Table A.5. Proxool connection pool properties
Property | Description |
---|---|
hibernate.proxool.xml | Configure Proxool provider using an XML file (.xml is appended automatically) |
hibernate.proxool.properties | Configure the Proxool provider using a properties file (.properties is appended automatically) |
hibernate.proxool.existing_pool | Whether to configure the Proxool provider from an existing pool |
hibernate.proxool.pool_alias | Proxool pool alias to use. Required. |
For information on specific configuration of Proxool, refer to the Proxool documentation available from http://proxool.sourceforge.net/.