13.2.1. About JPA
The Java Persistence API (JPA) is the standard for using persistence in Java projects. Java EE 6 applications use the Java Persistence 2.0 specification, documented here: http://www.jcp.org/en/jsr/detail?id=317.
Hibernate EntityManager implements the programming interfaces and life-cycle rules defined by the specification. It provides JBoss EAP 6 with a complete Java Persistence solution.
JBoss EAP 6 is 100% compliant with the Java Persistence 2.0 specification. Hibernate also provides additional features to the specification.
To get started with JPA and JBoss EAP 6, refer to the bean-validation, greeter, and kitchensink quickstarts: Section 1.4.1.1, “Access the Quickstarts”.
13.2.4. Configuration
13.2.4.1. Hibernate Configuration Properties
Table 13.1. Hibernate Java Properties
Property Name | Description |
hibernate.dialect | The classname of a Hibernate In most cases Hibernate will be able to choose the correct |
hibernate.show_sql | Boolean. Writes all SQL statements to console. This is an alternative to setting the log category |
hibernate.format_sql | Boolean. Pretty print the SQL in the log and console. |
hibernate.default_schema | Qualify unqualified table names with the given schema/tablespace in generated SQL. |
hibernate.default_catalog | Qualifies unqualified table names with the given catalog in generated SQL. |
hibernate.session_factory_name | The |
hibernate.max_fetch_depth | Sets a maximum "depth" for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A |
hibernate.default_batch_fetch_size | Sets a default size for Hibernate batch fetching of associations. The recommended values are |
hibernate.default_entity_mode | Sets a default mode for entity representation for all sessions opened from this |
hibernate.order_updates | Boolean. Forces Hibernate to order SQL updates by the primary key value of the items being updated. This will result in fewer transaction deadlocks in highly concurrent systems. |
hibernate.generate_statistics | Boolean. If enabled, Hibernate will collect statistics useful for performance tuning. |
hibernate.use_identifier_rollback | Boolean. If enabled, generated identifier properties will be reset to default values when objects are deleted. |
hibernate.use_sql_comments | Boolean. If turned on, Hibernate will generate comments inside the SQL, for easier debugging. Default value is |
hibernate.id.new_generator_mappings | Boolean. This property is relevant when using |
hibernate.ejb.naming_strategy | Chooses the If the application does not use EntityManager, follow the instructions here to configure the NamingStrategy: Hibernate Reference Documentation - Implementing a Naming Strategy. |
hibernate.ejb.naming_strategy_delegator | Specifies an
NOTE This property must not be used with If the application does not use EntityManager, follow the instructions here to configure the NamingStrategy: Hibernate Reference Documentation - Implementing a Naming Strategy. |
IMPORTANT
For hibernate.id.new_generator_mappings
, new applications should keep the default value of true
. Existing applications that used Hibernate 3.3.x may need to change it to false
to continue using a sequence object or table based generator, and maintain backward compatibility.
13.2.4.2. Hibernate JDBC and Connection Properties
Table 13.2. Properties
Property Name | Description |
hibernate.jdbc.fetch_size | A non-zero value that determines the JDBC fetch size (calls |
hibernate.jdbc.batch_size | A non-zero value enables use of JDBC2 batch updates by Hibernate. The recommended values are between |
hibernate.jdbc.batch_versioned_data | Boolean. Set this property to |
hibernate.jdbc.factory_class | Select a custom |
hibernate.jdbc.use_scrollable_resultset | Boolean. Enables use of JDBC2 scrollable resultsets by Hibernate. This property is only necessary when using user-supplied JDBC connections. Hibernate uses connection metadata otherwise. |
hibernate.jdbc.use_streams_for_binary | Boolean. This is a system-level property. Use streams when writing/reading |
hibernate.jdbc.use_get_generated_keys | Boolean. Enables use of JDBC3 |
hibernate.connection.provider_class | The classname of a custom |
hibernate.connection.isolation | Sets the JDBC transaction isolation level. Check |
hibernate.connection.autocommit | Boolean. This property is not recommended for use. Enables autocommit for JDBC pooled connections. |
hibernate.connection.release_mode | Specifies when Hibernate should release JDBC connections. By default, a JDBC connection is held until the session is explicitly closed or disconnected. The default value Available values are This setting only affects |
hibernate.connection.<propertyName> | Pass the JDBC property <propertyName> to |
hibernate.jndi.<propertyName> | Pass the property <propertyName> to the JNDI |
13.2.4.3. Hibernate Cache Properties
Table 13.3. Properties
Property Name | Description |
| The classname of a custom |
| Boolean. Optimizes second-level cache operation to minimize writes, at the cost of more frequent reads. This setting is most useful for clustered caches and, in Hibernate3, is enabled by default for clustered cache implementations. |
| Boolean. Enables the query cache. Individual queries still have to be set cacheable. |
| Boolean. Used to completely disable the second level cache, which is enabled by default for classes that specify a |
| The classname of a custom |
| A prefix to use for second-level cache region names. |
| Boolean. Forces Hibernate to store data in the second-level cache in a more human-friendly format. |
| Setting used to give the name of the default |
13.2.4.4. Hibernate Transaction Properties
Table 13.4. Properties
Property Name | Description |
| The classname of a |
| A JNDI name used by |
| The classname of a |
| Boolean. If enabled, the session will be automatically flushed during the before completion phase of the transaction. Built-in and automatic session context management is preferred. |
| Boolean. If enabled, the session will be automatically closed during the after completion phase of the transaction. Built-in and automatic session context management is preferred. |