Hibernate.org Community Documentation

- Prev
- Next

## Appendix A. Configuration properties

## A.1. General Configuration

hibernate.dialect | A fully-qualified classname | The classname of a Hibernate `org.hibernate.dialect.Dialect` from which Hibernate can generate SQL optimized for a particular relational database. In most cases Hibernate can choose the correct `org.hibernate.dialect.Dialect` implementation based on the JDBC metadata returned by the JDBC driver.
hibernate.show_sql | `true` or `false` | Write all SQL statements to the console. This is an alternative to setting the log category org.hibernate.SQL to debug.
hibernate.format_sql | `true` or `false` | 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 | `4`,`8`, or `16` | Default size for Hibernate batch fetching of associations.
hibernate.default_entity_mode | One of `dynamic-map`, `dom4j`, `pojo` | Default mode for entity representation for all sessions opened from this `SessionFactory`
hibernate.order_updates | `true` or `false` | 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.generate_statistics | `true` or `false` | Causes Hibernate to collect statistics for performance tuning.
hibernate.use_identifier_rollback | `true` or `false` | If true, generated identifier properties are reset to default values when objects are deleted.
hibernate.use_sql_comments | `true` or `false` | If true, Hibernate generates comments inside the SQL, for easier debugging.

## A.2. Database configuration

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 `5` and `30` | A non-zero value causes Hibernate to use JDBC2 batch updates.
hibernate.jdbc.batch_versioned_data | `true` or `false` | Set this property to `true` if 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.jdbc.factory_class | The fully-qualified class name of the factory | Select a custom `org.hibernate.jdbc.Batcher`. Irrelevant for most applications.
hibernate.jdbc.use_scrollable_resultset | `true` or `false` | 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 | `true` or `false` | 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 | `true` or `false` | 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.

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 | `true` or `false` | 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 | `true` or `false` | Enables the query cache. You still need to set individual queries to be cachable.
hibernate.cache.use_second_level_cache | `true` or `false` | 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 | `true` or `false` | Forces Hibernate to store data in the second-level cache in a more human-readable format.

Table A.3. Transactions properties

Property | Example | Purpose
--- | --- | ---
hibernate.transaction.factory_class | A fully-qualified classname | The classname of a `TransactionFactory` to use with Hibernate Transaction API. The default is `JDBCTransactionFactory`).
jta.UserTransaction | A JNDI name | The `JTATransactionFactory` needs a JNDI name to obtain the JTA UserTransaction from the application server.
hibernate.transaction.manager_lookup_class | A fully-qualified classname | The classname of a `TransactionManagerLookup`, which is used in conjunction with JVM-level or the hilo generator in a JTA environment.
hibernate.transaction.flush_before_completion | `true` or `false` | 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 | `true` or `false` | 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.

## Note

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 `jta`, `thread`, `managed`, or `custom.Class` | Supply a custom strategy for the scoping of the `Current` Session.
factory_class | `org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory` or `org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory` | Chooses the HQL parser implementation.
query.substitutions | `hqlLiteral=SQL_LITERAL` or `hqlFunction=SQLFUNC` | Map from tokens in Hibernate queries to SQL tokens, such as function or literal names.
hbm2ddl.auto | `validate`, `update`, `create`, `create-drop` | 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.
cglib.use_reflection_optimizer | `true` or `false` | If enabled, Hibernate uses CGLIB instead of runtime reflection. This is a system-level property. Reflection is useful for troubleshooting. Hibernate always requires CGLIB even if you disable the optimizer. You cannot set this property in hibernate.cfg.xml.

## A.3. Connection pool properties

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.

## Note

For information on specific configuration of Proxool, refer to the Proxool documentation available from http://proxool.sourceforge.net/.

- PrevChapter 16. Multi-tenancy
- Up
- Home
- NextAppendix B. Legacy Hibernate Criteria Queries