|
Hibernate example source code file (appendix-Configuration_Properties.xml)
This example Hibernate source code file (appendix-Configuration_Properties.xml) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The Hibernate appendix-Configuration_Properties.xml source code
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "Hibernate_Development_Guide.ent">
%BOOK_ENTITIES;
]>
<appendix id="appendix-Configuration_Properties">
<title>Configuration properties
<section>
<title>General Configuration
<informaltable>
<tgroup cols="3">
<colspec colwidth="100px" />
<colspec colwidth="120px" />
<colspec colwidth="250px" />
<tbody>
<row>
<entry>hibernate.dialect
<entry>A fully-qualified classname
<entry>
<para>
The classname of a Hibernate <classname>org.hibernate.dialect.Dialect from which Hibernate
can generate SQL optimized for a particular relational database.
</para>
<para>
In most cases Hibernate can choose the correct <classname>org.hibernate.dialect.Dialect
implementation based on the JDBC metadata returned by the JDBC driver.
</para>
</entry>
</row>
<row>
<entry>hibernate.show_sql
<entry>true or false
<entry>Write all SQL statements to the console. This is an alternative to setting the log category
<property>org.hibernate.SQL to debug.
</row>
<row>
<entry>hibernate.format_sql
<entry>true or false
<entry>Pretty-print the SQL in the log and console.
</row>
<row>
<entry>hibernate.default_schema
<entry>A schema name
<entry>Qualify unqualified table names with the given schema or tablespace in generated SQL.
</row>
<row>
<entry>hibernate.default_catalog
<entry>A catalog name
<entry>Qualifies unqualified table names with the given catalog in generated SQL.
</row>
<row>
<entry>hibernate.session_factory_name
<entry>A JNDI name
<entry>The org.hibernate.SessionFactory is automatically bound to this name in JNDI
after it is created.</entry>
</row>
<row>
<entry>hibernate.max_fetch_depth
<entry>A value between 0 and 3
<entry>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 <literal>0 disables default outer
join fetching.</entry>
</row>
<row>
<entry>hibernate.default_batch_fetch_size
<entry>4,8, or 16
<entry>Default size for Hibernate batch fetching of associations.
</row>
<row>
<entry>hibernate.default_entity_mode
<entry>One of dynamic-map, dom4j,
<literal>pojo
<entry>Default mode for entity representation for all sessions opened from this
<classname>SessionFactory
</row>
<row>
<entry>hibernate.order_updates
<entry>true or false
<entry>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.</entry>
</row>
<row>
<entry>hibernate.generate_statistics
<entry>true or false
<entry>Causes Hibernate to collect statistics for performance tuning.
</row>
<row>
<entry>hibernate.use_identifier_rollback
<entry>true or false
<entry>If true, generated identifier properties are reset to default values when objects are
deleted.</entry>
</row>
<row>
<entry>hibernate.use_sql_comments
<entry>true or false
<entry>If true, Hibernate generates comments inside the SQL, for easier debugging.
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title>Database configuration
<table>
<title>JDBC properties
<tgroup cols="3">
<thead>
<row>
<entry>Property
<entry>Example
<entry>Purpose
</row>
</thead>
<tbody>
<row>
<entry>hibernate.jdbc.fetch_size
<entry>0 or an integer
<entry>A non-zero value determines the JDBC fetch size, by calling
<methodname>Statement.setFetchSize().
</row>
<row>
<entry>hibernate.jdbc.batch_size
<entry>A value between 5 and 30
<entry>A non-zero value causes Hibernate to use JDBC2 batch updates.
</row>
<row>
<entry>hibernate.jdbc.batch_versioned_data
<entry>true or false
<entry>Set this property to true if your JDBC driver returns correct row counts
from <methodname>executeBatch(). This option is usually safe, but is disabled by default. If
enabled, Hibernate uses batched DML for automatically versioned data.</para>
</row>
<row>
<entry>hibernate.jdbc.factory_class
<entry>The fully-qualified class name of the factory
<entry>Select a custom org.hibernate.jdbc.Batcher. Irrelevant for most
applications.</para>
</row>
<row>
<entry>hibernate.jdbc.use_scrollable_resultset
<entry>true or false
<entry>Enables Hibernate to use JDBC2 scrollable resultsets. This property is only relevant for
user-supplied JDBC connections. Otherwise, Hibernate uses connection metadata.</entry>
</row>
<row>
<entry>hibernate.jdbc.use_streams_for_binary
<entry>true or false
<entry>Use streams when writing or reading binary or serializable types to
or from JDBC. This is a system-level property.</para>
</row>
<row>
<entry>hibernate.jdbc.use_get_generated_keys
<entry>true or false
<entry>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.</para>
</row>
</tbody>
</tgroup>
</table>
<table>
<title>Cache Properties
<tgroup cols="3">
<colspec colwidth="100px" />
<colspec colwidth="100px" />
<colspec colwidth="240px" />
<thead>
<row>
<entry>Property
<entry>Example
<entry>Purpose
</row>
</thead>
<tbody>
<row>
<entry>hibernate.cache.provider_class
<entry>Fully-qualified classname
<entry>The classname of a custom CacheProvider.
</row>
<row>
<entry>hibernate.cache.use_minimal_puts
<entry>true or false
<entry>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.</entry>
</row>
<row>
<entry>hibernate.cache.use_query_cache
<entry>true or false
<entry>Enables the query cache. You still need to set individual queries to be cachable.
</row>
<row>
<entry>hibernate.cache.use_second_level_cache true or
<literal>false Completely disable the second level cache, which is enabled
by default for classes which specify a <cache> mapping.</entry>
</row>
<row>
<entry>hibernate.cache.query_cache_factory
<entry>Fully-qualified classname
<entry>A custom QueryCache interface. The default is the built-in
<interfacename>StandardQueryCache.
</row>
<row>
<entry>hibernate.cache.region_prefix
<entry>A string
<entry>A prefix for second-level cache region names.
</row>
<row>
<entry>hibernate.cache.use_structured_entries
<entry>true or false
<entry>Forces Hibernate to store data in the second-level cache in a more human-readable format.
</row>
</tbody>
</tgroup>
</table>
<table>
<title>Transactions properties
<tgroup cols="3">
<colspec colwidth="100px" />
<colspec colwidth="100px" />
<colspec colwidth="240px" />
<thead>
<row>
<entry>Property
<entry>Example
<entry>Purpose
</row>
</thead>
<tbody>
<row>
<entry>hibernate.transaction.factory_class
<entry>A fully-qualified classname
<entry>The classname of a TransactionFactory to use with Hibernate Transaction API. The
default is <classname>JDBCTransactionFactory).
</row>
<row>
<entry>jta.UserTransaction
<entry>A JNDI name
<entry>The JTATransactionFactory needs a JNDI name to obtain the JTA
UserTransaction from the application server.</para>
</row>
<row>
<entry>hibernate.transaction.manager_lookup_class
<entry>A fully-qualified classname
<entry>The classname of a TransactionManagerLookup, which is used in
conjunction with JVM-level or the hilo generator in a JTA environment.</para>
</row>
<row>
<entry>hibernate.transaction.flush_before_completion
<entry>true or false
<entry>Causes the session be flushed during the before completion phase of the
transaction. If possible, use built-in and automatic session context management instead.</entry>
</row>
<row>
<entry>hibernate.transaction.auto_close_session
<entry>true or false
<entry>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.</entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>
Each of the properties in the following table are prefixed by <literal>hibernate.. It has been removed
in the table to conserve space.
</para>
</note>
<table>
<title>Miscellaneous properties
<tgroup cols="3">
<thead>
<row>
<entry>Property
<entry>Example
<entry>Purpose
</row>
</thead>
<tbody>
<row>
<entry>current_session_context_class
<entry>One of jta, thread, managed, or
<literal>custom.Class
<entry>Supply a custom strategy for the scoping of the Current
Session.</para>
</row>
<row>
<entry>factory_class
<entry>org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory or
<literal>org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory
<entry>Chooses the HQL parser implementation.
</row>
<row>
<entry>query.substitutions
<entry>hqlLiteral=SQL_LITERAL or hqlFunction=SQLFUNC
</para>
<entry>Map from tokens in Hibernate queries to SQL tokens, such as function or literal names.
</row>
<row>
<entry>hbm2ddl.auto
<entry>validate, update, create,
<literal>create-drop
<entry>Validates or exports schema DDL to the database when the SessionFactory is
created. With <command>create-drop, the database schema is dropped when the
<classname>SessionFactory is closed explicitly.
</row>
<row>
<entry>cglib.use_reflection_optimizer
<entry>true or false
<entry>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.</entry>
</row>
</tbody>
</tgroup>
</table>
</section>
<section>
<title>Connection pool properties
<itemizedlist>
<title>c3p0 connection pool properties
<listitem>hibernate.c3p0.min_size
<listitem>hibernate.c3p0.max_size
<listitem>hibernate.c3p0.timeout
<listitem>hibernate.c3p0.max_statements
</itemizedlist>
<table>
<title>Proxool connection pool properties
<tgroup cols="2">
<colspec colwidth="100px" />
<colspec colwidth="340px" />
<thead>
<row>
<entry>Property
<entry>Description
</row>
</thead>
<tbody>
<row>
<entry>hibernate.proxool.xml
<entry>Configure Proxool provider using an XML file (.xml is appended automatically)
</row>
<row>
<entry>hibernate.proxool.properties
<entry>Configure the Proxool provider using a properties file (.properties is appended
automatically)</entry>
</row>
<row>
<entry>hibernate.proxool.existing_pool
<entry>Whether to configure the Proxool provider from an existing pool
</row>
<row>
<entry>hibernate.proxool.pool_alias
<entry>Proxool pool alias to use. Required.
</row>
</tbody>
</tgroup>
</table>
<note>
<para>
For information on specific configuration of Proxool, refer to the Proxool documentation available from <ulink
url="http://proxool.sourceforge.net/" />.
</para>
</note>
</section>
</appendix>
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate appendix-Configuration_Properties.xml source code file:
|