Hibernate SVN: r12927 - maven-poms/trunk/core-parent.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-08-13 16:04:46 -0400 (Mon, 13 Aug 2007)
New Revision: 12927
Modified:
maven-poms/trunk/core-parent/pom.xml
Log:
fixed logging dependencies
Modified: maven-poms/trunk/core-parent/pom.xml
===================================================================
--- maven-poms/trunk/core-parent/pom.xml 2007-08-13 20:04:26 UTC (rev 12926)
+++ maven-poms/trunk/core-parent/pom.xml 2007-08-13 20:04:46 UTC (rev 12927)
@@ -199,6 +199,21 @@
<hibernate.core.reports.aggregate>false</hibernate.core.reports.aggregate>
</properties>
+ <dependencies>
+ <!-- The basic slf4j API -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+<!--
<dependencyManagement>
<dependencies>
<dependency>
@@ -206,33 +221,10 @@
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
- </dependency>
- <!-- Force commons-logging out of deps, even transitive ones, based on this "hack" -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>99.0-does-not-exist</version>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- <version>99.0-does-not-exist</version>
- </dependency>
- <!-- The slf4j commons-logging replacement -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <version>1.4.2</version>
- </dependency>
- <!-- The basic slf4j API -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.2</version>
- </dependency>
</dependencies>
</dependencyManagement>
-
+-->
<distributionManagement>
<repository>
<!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
17 years, 4 months
Hibernate SVN: r12926 - in core/trunk/documentation/manual: pt-BR/src/main/docbook/modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: d.plentz
Date: 2007-08-13 16:04:26 -0400 (Mon, 13 Aug 2007)
New Revision: 12926
Modified:
core/trunk/documentation/manual/en-US/src/main/docbook/modules/configuration.xml
core/trunk/documentation/manual/pt-BR/src/main/docbook/modules/configuration.xml
Log:
[HHH-2726] spelling o your CLASSPATH
Modified: core/trunk/documentation/manual/en-US/src/main/docbook/modules/configuration.xml
===================================================================
--- core/trunk/documentation/manual/en-US/src/main/docbook/modules/configuration.xml 2007-08-13 20:04:19 UTC (rev 12925)
+++ core/trunk/documentation/manual/en-US/src/main/docbook/modules/configuration.xml 2007-08-13 20:04:26 UTC (rev 12926)
@@ -1,1738 +1,1738 @@
-<chapter id="session-configuration" revision="1">
-
- <title>Configuration</title>
-
- <para>
- Because Hibernate is designed to operate in many different environments, there
- are a large number of configuration parameters. Fortunately, most have sensible
- default values and Hibernate is distributed with an example
- <literal>hibernate.properties</literal> file in <literal>etc/</literal> that shows
- the various options. Just put the example file in your classpath and customize it.
- </para>
-
- <sect1 id="configuration-programmatic" revision="1">
- <title>Programmatic configuration</title>
-
- <para>
- An instance of <literal>org.hibernate.cfg.Configuration</literal>
- represents an entire set of mappings of an application's Java types to an
- SQL database. The <literal>Configuration</literal> is used to build an
- (immutable) <literal>SessionFactory</literal>. The mappings are compiled
- from various XML mapping files.
- </para>
-
- <para>
- You may obtain a <literal>Configuration</literal> instance by instantiating
- it directly and specifying XML mapping documents. If the mapping files are
- in the classpath, use <literal>addResource()</literal>:
- </para>
-
- <programlisting><![CDATA[Configuration cfg = new Configuration()
- .addResource("Item.hbm.xml")
- .addResource("Bid.hbm.xml");]]></programlisting>
-
- <para>
- An alternative (sometimes better) way is to specify the mapped class, and
- let Hibernate find the mapping document for you:
- </para>
-
- <programlisting><![CDATA[Configuration cfg = new Configuration()
- .addClass(org.hibernate.auction.Item.class)
- .addClass(org.hibernate.auction.Bid.class);]]></programlisting>
-
- <para>
- Then Hibernate will look for mapping files named
- <literal>/org/hibernate/auction/Item.hbm.xml</literal> and
- <literal>/org/hibernate/auction/Bid.hbm.xml</literal> in the classpath.
- This approach eliminates any hardcoded filenames.
- </para>
-
- <para>
- A <literal>Configuration</literal> also allows you to specify configuration
- properties:
- </para>
-
- <programlisting><![CDATA[Configuration cfg = new Configuration()
- .addClass(org.hibernate.auction.Item.class)
- .addClass(org.hibernate.auction.Bid.class)
- .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
- .setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/test")
- .setProperty("hibernate.order_updates", "true");]]></programlisting>
-
- <para>
- This is not the only way to pass configuration properties to Hibernate.
- The various options include:
- </para>
-
- <orderedlist spacing="compact">
- <listitem>
- <para>
- Pass an instance of <literal>java.util.Properties</literal> to
- <literal>Configuration.setProperties()</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- Place <literal>hibernate.properties</literal> in a root directory
- of the classpath.
- </para>
- </listitem>
- <listitem>
- <para>
- Set <literal>System</literal> properties using
- <literal>java -Dproperty=value</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- Include <literal><property></literal> elements in
- <literal>hibernate.cfg.xml</literal> (discussed later).
- </para>
- </listitem>
- </orderedlist>
-
- <para>
- <literal>hibernate.properties</literal> is the easiest approach if you
- want to get started quickly.
- </para>
-
- <para>
- The <literal>Configuration</literal> is intended as a startup-time object,
- to be discarded once a <literal>SessionFactory</literal> is created.
- </para>
-
- </sect1>
-
- <sect1 id="configuration-sessionfactory">
- <title>Obtaining a SessionFactory</title>
-
- <para>
- When all mappings have been parsed by the <literal>Configuration</literal>,
- the application must obtain a factory for <literal>Session</literal> instances.
- This factory is intended to be shared by all application threads:
- </para>
-
- <programlisting><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
-
- <para>
- Hibernate does allow your application to instantiate more than one
- <literal>SessionFactory</literal>. This is useful if you are using more than
- one database.
- </para>
-
- </sect1>
-
- <sect1 id="configuration-hibernatejdbc" revision="1">
- <title>JDBC connections</title>
-
- <para>
- Usually, you want to have the <literal>SessionFactory</literal> create and pool JDBC
- connections for you. If you take this approach, opening a <literal>Session</literal>
- is as simple as:
- </para>
-
- <programlisting><![CDATA[Session session = sessions.openSession(); // open a new Session]]></programlisting>
-
- <para>
- As soon as you do something that requires access to the database, a JDBC connection
- will be obtained from the pool.
- </para>
-
- <para>
- For this to work, we need to pass some JDBC connection properties to Hibernate.
- All Hibernate property names and semantics are defined on the class
- <literal>org.hibernate.cfg.Environment</literal>. We will now describe the most
- important settings for JDBC connection configuration.
- </para>
-
- <para>
- Hibernate will obtain (and pool) connections using <literal>java.sql.DriverManager</literal>
- if you set the following properties:
- </para>
-
- <table frame="topbot">
- <title>Hibernate JDBC Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.connection.driver_class</literal>
- </entry>
- <entry>
- <emphasis>JDBC driver class</emphasis>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.url</literal>
- </entry>
- <entry>
- <emphasis>JDBC URL</emphasis>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.username</literal>
- </entry>
- <entry>
- <emphasis>database user</emphasis>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.password</literal>
- </entry>
- <entry>
- <emphasis>database user password</emphasis>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.pool_size</literal>
- </entry>
- <entry>
- <emphasis>maximum number of pooled connections</emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- Hibernate's own connection pooling algorithm is however quite rudimentary.
- It is intended to help you get started and is <emphasis>not intended for use
- in a production system</emphasis> or even for performance testing. You should
- use a third party pool for best performance and stability. Just replace the
- <literal>hibernate.connection.pool_size</literal> property with connection
- pool specific settings. This will turn off Hibernate's internal pool. For
- example, you might like to use C3P0.
- </para>
-
- <para>
- C3P0 is an open source JDBC connection pool distributed along with
- Hibernate in the <literal>lib</literal> directory. Hibernate will use its
- <literal>C3P0ConnectionProvider</literal> for connection pooling if you set
- <literal>hibernate.c3p0.*</literal> properties. If you'd like to use Proxool
- refer to the packaged <literal>hibernate.properties</literal> and the Hibernate
- web site for more information.
- </para>
-
- <para>
- Here is an example <literal>hibernate.properties</literal> file for C3P0:
- </para>
-
- <programlisting id="c3p0-configuration" revision="1"><![CDATA[hibernate.connection.driver_class = org.postgresql.Driver
-hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
-hibernate.connection.username = myuser
-hibernate.connection.password = secret
-hibernate.c3p0.min_size=5
-hibernate.c3p0.max_size=20
-hibernate.c3p0.timeout=1800
-hibernate.c3p0.max_statements=50
-hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
-
- <para>
- For use inside an application server, you should almost always configure
- Hibernate to obtain connections from an application server
- <literal>Datasource</literal> registered in JNDI. You'll need to set at
- least one of the following properties:
- </para>
-
- <table frame="topbot">
- <title>Hibernate Datasource Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.connection.datasource</literal>
- </entry>
- <entry>
- <emphasis>datasource JNDI name</emphasis>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jndi.url</literal>
- </entry>
- <entry>
- <emphasis>URL of the JNDI provider</emphasis> (optional)
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jndi.class</literal>
- </entry>
- <entry>
- <emphasis>class of the JNDI <literal>InitialContextFactory</literal></emphasis> (optional)
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.username</literal>
- </entry>
- <entry>
- <emphasis>database user</emphasis> (optional)
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.password</literal>
- </entry>
- <entry>
- <emphasis>database user password</emphasis> (optional)
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- Here's an example <literal>hibernate.properties</literal> file for an
- application server provided JNDI datasource:
- </para>
-
- <programlisting><![CDATA[hibernate.connection.datasource = java:/comp/env/jdbc/test
-hibernate.transaction.factory_class = \
- org.hibernate.transaction.JTATransactionFactory
-hibernate.transaction.manager_lookup_class = \
- org.hibernate.transaction.JBossTransactionManagerLookup
-hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
-
- <para>
- JDBC connections obtained from a JNDI datasource will automatically participate
- in the container-managed transactions of the application server.
- </para>
-
- <para>
- Arbitrary connection properties may be given by prepending
- "<literal>hibernate.connection</literal>" to the property name. For example, you
- may specify a <literal>charSet</literal> using <literal>hibernate.connection.charSet</literal>.
- </para>
-
- <para>
- You may define your own plugin strategy for obtaining JDBC connections by implementing the
- interface <literal>org.hibernate.connection.ConnectionProvider</literal>. You may select
- a custom implementation by setting <literal>hibernate.connection.provider_class</literal>.
- </para>
-
- </sect1>
-
- <sect1 id="configuration-optional" revision="1">
- <title>Optional configuration properties</title>
-
- <para>
- There are a number of other properties that control the behaviour of Hibernate
- at runtime. All are optional and have reasonable default values.
- </para>
-
- <para>
- <emphasis>Warning: some of these properties are "system-level" only.</emphasis>
- System-level properties can be set only via <literal>java -Dproperty=value</literal> or
- <literal>hibernate.properties</literal>. They may <emphasis>not</emphasis> be set by
- the other techniques described above.
- </para>
-
- <table frame="topbot" id="configuration-optional-properties" revision="8">
- <title>Hibernate Configuration Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.dialect</literal>
- </entry>
- <entry>
- The classname of a Hibernate <literal>Dialect</literal> which
- allows Hibernate to generate SQL optimized for a particular
- relational database.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>full.classname.of.Dialect</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.show_sql</literal>
- </entry>
- <entry>
- Write all SQL statements to console. This is an alternative
- to setting the log category <literal>org.hibernate.SQL</literal>
- to <literal>debug</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.format_sql</literal>
- </entry>
- <entry>
- Pretty print the SQL in the log and console.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.default_schema</literal>
- </entry>
- <entry>
- Qualify unqualified table names with the given schema/tablespace
- in generated SQL.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>SCHEMA_NAME</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.default_catalog</literal>
- </entry>
- <entry>
- Qualify unqualified table names with the given catalog
- in generated SQL.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>CATALOG_NAME</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.session_factory_name</literal>
- </entry>
- <entry>
- The <literal>SessionFactory</literal> will be automatically
- bound to this name in JNDI after it has been created.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>jndi/composite/name</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.max_fetch_depth</literal>
- </entry>
- <entry>
- Set a maximum "depth" for the outer join fetch tree
- for single-ended associations (one-to-one, many-to-one).
- A <literal>0</literal> disables default outer join fetching.
- <para>
- <emphasis role="strong">eg.</emphasis>
- recommended values between <literal>0</literal> and
- <literal>3</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.default_batch_fetch_size</literal>
- </entry>
- <entry>
- Set a default size for Hibernate batch fetching of associations.
- <para>
- <emphasis role="strong">eg.</emphasis>
- recommended values <literal>4</literal>, <literal>8</literal>,
- <literal>16</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.default_entity_mode</literal>
- </entry>
- <entry>
- Set a default mode for entity representation for all sessions
- opened from this <literal>SessionFactory</literal>
- <para>
- <literal>dynamic-map</literal>, <literal>dom4j</literal>,
- <literal>pojo</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.order_updates</literal>
- </entry>
- <entry>
- Force 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.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.generate_statistics</literal>
- </entry>
- <entry>
- If enabled, Hibernate will collect statistics useful for
- performance tuning.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.use_identifier_rollback</literal>
- </entry>
- <entry>
- If enabled, generated identifier properties will be
- reset to default values when objects are deleted.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.use_sql_comments</literal>
- </entry>
- <entry>
- If turned on, Hibernate will generate comments inside the SQL, for
- easier debugging, defaults to <literal>false</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table frame="topbot" id="configuration-jdbc-properties" revision="8">
- <title>Hibernate JDBC and Connection Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.jdbc.fetch_size</literal>
- </entry>
- <entry>
- A non-zero value determines the JDBC fetch size (calls
- <literal>Statement.setFetchSize()</literal>).
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.batch_size</literal>
- </entry>
- <entry>
- A non-zero value enables use of JDBC2 batch updates by Hibernate.
- <para>
- <emphasis role="strong">eg.</emphasis>
- recommended values between <literal>5</literal> and <literal>30</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.batch_versioned_data</literal>
- </entry>
- <entry>
- Set this property to <literal>true</literal> if your JDBC driver returns
- correct row counts from <literal>executeBatch()</literal> (it is usually
- safe to turn this option on). Hibernate will then use batched DML for
- automatically versioned data. Defaults to <literal>false</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.factory_class</literal>
- </entry>
- <entry>
- Select a custom <literal>Batcher</literal>. Most applications
- will not need this configuration property.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.BatcherFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.use_scrollable_resultset</literal>
- </entry>
- <entry>
- Enables use of JDBC2 scrollable resultsets by Hibernate.
- This property is only necessary when using user supplied
- JDBC connections, Hibernate uses connection metadata otherwise.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.use_streams_for_binary</literal>
- </entry>
- <entry>
- Use streams when writing/reading <literal>binary</literal>
- or <literal>serializable</literal> types to/from JDBC
- (system-level property).
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jdbc.use_get_generated_keys</literal>
- </entry>
- <entry>
- Enable use of JDBC3 <literal>PreparedStatement.getGeneratedKeys()</literal>
- to retrieve natively generated keys after insert. Requires JDBC3+ driver
- and JRE1.4+, set to false if your driver has problems with the Hibernate
- identifier generators. By default, tries to determine the driver capabilities
- using connection metadata.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.provider_class</literal>
- </entry>
- <entry>
- The classname of a custom <literal>ConnectionProvider</literal> which provides
- JDBC connections to Hibernate.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.ConnectionProvider</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.isolation</literal>
- </entry>
- <entry>
- Set the JDBC transaction isolation level. Check
- <literal>java.sql.Connection</literal> for meaningful values but
- note that most databases do not support all isolation levels.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>1, 2, 4, 8</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.autocommit</literal>
- </entry>
- <entry>
- Enables autocommit for JDBC pooled connections (not recommended).
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.release_mode</literal>
- </entry>
- <entry>
- Specify when Hibernate should release JDBC connections. By default,
- a JDBC connection is held until the session is explicitly closed or
- disconnected. For an application server JTA datasource, you should use
- <literal>after_statement</literal> to aggressively release connections
- after every JDBC call. For a non-JTA connection, it often makes sense to
- release the connection at the end of each transaction, by using
- <literal>after_transaction</literal>. <literal>auto</literal> will
- choose <literal>after_statement</literal> for the JTA and CMT transaction
- strategies and <literal>after_transaction</literal> for the JDBC
- transaction strategy.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>auto</literal> (default) | <literal>on_close</literal> |
- <literal>after_transaction</literal> | <literal>after_statement</literal>
- </para>
- <para>
- Note that this setting only affects <literal>Session</literal>s returned from
- <literal>SessionFactory.openSession</literal>. For <literal>Session</literal>s
- obtained through <literal>SessionFactory.getCurrentSession</literal>, the
- <literal>CurrentSessionContext</literal> implementation configured for use
- controls the connection release mode for those <literal>Session</literal>s.
- See <xref linkend="architecture-current-session"/>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.connection.<emphasis><propertyName></emphasis></literal>
- </entry>
- <entry>
- Pass the JDBC property <literal>propertyName</literal>
- to <literal>DriverManager.getConnection()</literal>.
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.jndi.<emphasis><propertyName></emphasis></literal>
- </entry>
- <entry>
- Pass the property <literal>propertyName</literal> to
- the JNDI <literal>InitialContextFactory</literal>.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table frame="topbot" id="configuration-cache-properties" revision="7">
- <title>Hibernate Cache Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.cache.provider_class</literal>
- </entry>
- <entry>
- The classname of a custom <literal>CacheProvider</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.CacheProvider</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_minimal_puts</literal>
- </entry>
- <entry>
- Optimize 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.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_query_cache</literal>
- </entry>
- <entry>
- Enable the query cache, individual queries still have to be set cachable.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_second_level_cache</literal>
- </entry>
- <entry>
- May be used to completely disable the second level cache, which is enabled
- by default for classes which specify a <literal><cache></literal>
- mapping.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.query_cache_factory</literal>
- </entry>
- <entry>
- The classname of a custom <literal>QueryCache</literal> interface,
- defaults to the built-in <literal>StandardQueryCache</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.QueryCache</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.region_prefix</literal>
- </entry>
- <entry>
- A prefix to use for second-level cache region names.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>prefix</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cache.use_structured_entries</literal>
- </entry>
- <entry>
- Forces Hibernate to store data in the second-level cache
- in a more human-friendly format.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true|false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table frame="topbot" id="configuration-transaction-properties" revision="9">
- <title>Hibernate Transaction Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.transaction.factory_class</literal>
- </entry>
- <entry>
- The classname of a <literal>TransactionFactory</literal>
- to use with Hibernate <literal>Transaction</literal> API
- (defaults to <literal>JDBCTransactionFactory</literal>).
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.TransactionFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>jta.UserTransaction</literal>
- </entry>
- <entry>
- A JNDI name used by <literal>JTATransactionFactory</literal> to
- obtain the JTA <literal>UserTransaction</literal> from the
- application server.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>jndi/composite/name</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.manager_lookup_class</literal>
- </entry>
- <entry>
- The classname of a <literal>TransactionManagerLookup</literal>
- - required when JVM-level caching is enabled or when using hilo
- generator in a JTA environment.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>classname.of.TransactionManagerLookup</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.flush_before_completion</literal>
- </entry>
- <entry>
- 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, see
- <xref linkend="architecture-current-session"/>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.transaction.auto_close_session</literal>
- </entry>
- <entry>
- If enabled, the session will be automatically closed during the
- after completion phase of the transaction. Built-in and
- utomatic session context management is preferred, see
- <xref linkend="architecture-current-session"/>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table frame="topbot" id="configuration-misc-properties" revision="10">
- <title>Miscellaneous Properties</title>
- <tgroup cols="2">
- <colspec colname="c1" colwidth="1*"/>
- <colspec colname="c2" colwidth="1*"/>
- <thead>
- <row>
- <entry>Property name</entry>
- <entry>Purpose</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>
- <literal>hibernate.current_session_context_class</literal>
- </entry>
- <entry>
- Supply a (custom) strategy for the scoping of the "current"
- <literal>Session</literal>. See
- <xref linkend="architecture-current-session"/> for more
- information about the built-in strategies.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>jta</literal> | <literal>thread</literal> |
- <literal>managed</literal> | <literal>custom.Class</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.query.factory_class</literal>
- </entry>
- <entry>
- Chooses the HQL parser implementation.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>org.hibernate.hql.ast.ASTQueryTranslatorFactory</literal> or
- <literal>org.hibernate.hql.classic.ClassicQueryTranslatorFactory</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.query.substitutions</literal>
- </entry>
- <entry>
- Mapping from tokens in Hibernate queries to SQL tokens
- (tokens might be function or literal names, for example).
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.hbm2ddl.auto</literal>
- </entry>
- <entry>
- Automatically validate or export schema DDL to the database
- when the <literal>SessionFactory</literal> is created. With
- <literal>create-drop</literal>, the database schema will be
- dropped when the <literal>SessionFactory</literal> is closed
- explicitly.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>validate</literal> | <literal>update</literal> |
- <literal>create</literal> | <literal>create-drop</literal>
- </para>
- </entry>
- </row>
- <row>
- <entry>
- <literal>hibernate.cglib.use_reflection_optimizer</literal>
- </entry>
- <entry>
- Enables use of CGLIB instead of runtime reflection (System-level
- property). Reflection can sometimes be useful when troubleshooting,
- note that Hibernate always requires CGLIB even if you turn off the
- optimizer. You can not set this property in <literal>hibernate.cfg.xml</literal>.
- <para>
- <emphasis role="strong">eg.</emphasis>
- <literal>true</literal> | <literal>false</literal>
- </para>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <sect2 id="configuration-optional-dialects" revision="1">
- <title>SQL Dialects</title>
-
- <para>
- You should always set the <literal>hibernate.dialect</literal> property to the correct
- <literal>org.hibernate.dialect.Dialect</literal> subclass for your database. If you
- specify a dialect, Hibernate will use sensible defaults for some of the
- other properties listed above, saving you the effort of specifying them manually.
- </para>
-
- <table frame="topbot" id="sql-dialects" revision="2">
- <title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title>
- <tgroup cols="2">
- <colspec colwidth="1*"/>
- <colspec colwidth="2.5*"/>
- <thead>
- <row>
- <entry>RDBMS</entry>
- <entry>Dialect</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>DB2</entry> <entry><literal>org.hibernate.dialect.DB2Dialect</literal></entry>
- </row>
- <row>
- <entry>DB2 AS/400</entry> <entry><literal>org.hibernate.dialect.DB2400Dialect</literal></entry>
- </row>
- <row>
- <entry>DB2 OS390</entry> <entry><literal>org.hibernate.dialect.DB2390Dialect</literal></entry>
- </row>
- <row>
- <entry>PostgreSQL</entry> <entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL</entry> <entry><literal>org.hibernate.dialect.MySQLDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL with InnoDB</entry> <entry><literal>org.hibernate.dialect.MySQLInnoDBDialect</literal></entry>
- </row>
- <row>
- <entry>MySQL with MyISAM</entry> <entry><literal>org.hibernate.dialect.MySQLMyISAMDialect</literal></entry>
- </row>
- <row>
- <entry>Oracle (any version)</entry> <entry><literal>org.hibernate.dialect.OracleDialect</literal></entry>
- </row>
- <row>
- <entry>Oracle 9i/10g</entry> <entry><literal>org.hibernate.dialect.Oracle9Dialect</literal></entry>
- </row>
- <row>
- <entry>Sybase</entry> <entry><literal>org.hibernate.dialect.SybaseDialect</literal></entry>
- </row>
- <row>
- <entry>Sybase Anywhere</entry> <entry><literal>org.hibernate.dialect.SybaseAnywhereDialect</literal></entry>
- </row>
- <row>
- <entry>Microsoft SQL Server</entry> <entry><literal>org.hibernate.dialect.SQLServerDialect</literal></entry>
- </row>
- <row>
- <entry>SAP DB</entry> <entry><literal>org.hibernate.dialect.SAPDBDialect</literal></entry>
- </row>
- <row>
- <entry>Informix</entry> <entry><literal>org.hibernate.dialect.InformixDialect</literal></entry>
- </row>
- <row>
- <entry>HypersonicSQL</entry> <entry><literal>org.hibernate.dialect.HSQLDialect</literal></entry>
- </row>
- <row>
- <entry>Ingres</entry> <entry><literal>org.hibernate.dialect.IngresDialect</literal></entry>
- </row>
- <row>
- <entry>Progress</entry> <entry><literal>org.hibernate.dialect.ProgressDialect</literal></entry>
- </row>
- <row>
- <entry>Mckoi SQL</entry> <entry><literal>org.hibernate.dialect.MckoiDialect</literal></entry>
- </row>
- <row>
- <entry>Interbase</entry> <entry><literal>org.hibernate.dialect.InterbaseDialect</literal></entry>
- </row>
- <row>
- <entry>Pointbase</entry> <entry><literal>org.hibernate.dialect.PointbaseDialect</literal></entry>
- </row>
- <row>
- <entry>FrontBase</entry> <entry><literal>org.hibernate.dialect.FrontbaseDialect</literal></entry>
- </row>
- <row>
- <entry>Firebird</entry> <entry><literal>org.hibernate.dialect.FirebirdDialect</literal></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- </sect2>
-
- <sect2 id="configuration-optional-outerjoin" revision="4">
- <title>Outer Join Fetching</title>
-
- <para>
- If your database supports ANSI, Oracle or Sybase style outer joins, <emphasis>outer join
- fetching</emphasis> will often increase performance by limiting the number of round
- trips to and from the database (at the cost of possibly more work performed by
- the database itself). Outer join fetching allows a whole graph of objects connected
- by many-to-one, one-to-many, many-to-many and one-to-one associations to be retrieved
- in a single SQL <literal>SELECT</literal>.
- </para>
-
- <para>
- Outer join fetching may be disabled <emphasis>globally</emphasis> by setting
- the property <literal>hibernate.max_fetch_depth</literal> to <literal>0</literal>.
- A setting of <literal>1</literal> or higher enables outer join fetching for
- one-to-one and many-to-one associations which have been mapped with
- <literal>fetch="join"</literal>.
- </para>
-
- <para>
- See <xref linkend="performance-fetching"/> for more information.
- </para>
-
- </sect2>
-
- <sect2 id="configuration-optional-binarystreams" revision="1">
- <title>Binary Streams</title>
-
- <para>
- Oracle limits the size of <literal>byte</literal> arrays that may
- be passed to/from its JDBC driver. If you wish to use large instances of
- <literal>binary</literal> or <literal>serializable</literal> type, you should
- enable <literal>hibernate.jdbc.use_streams_for_binary</literal>.
- <emphasis>This is a system-level setting only.</emphasis>
- </para>
-
- </sect2>
-
- <sect2 id="configuration-optional-cacheprovider" revision="2">
- <title>Second-level and query cache</title>
-
- <para>
- The properties prefixed by <literal>hibernate.cache</literal>
- allow you to use a process or cluster scoped second-level cache system
- with Hibernate. See the <xref linkend="performance-cache"/> for
- more details.
- </para>
-
- </sect2>
-
- <sect2 id="configuration-optional-querysubstitution">
- <title>Query Language Substitution</title>
-
- <para>
- You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>.
- For example:
- </para>
-
- <programlisting>hibernate.query.substitutions true=1, false=0</programlisting>
-
- <para>
- would cause the tokens <literal>true</literal> and <literal>false</literal> to be translated to
- integer literals in the generated SQL.
- </para>
-
- <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting>
-
- <para>
- would allow you to rename the SQL <literal>LOWER</literal> function.
- </para>
-
- </sect2>
-
- <sect2 id="configuration-optional-statistics" revision="2">
- <title>Hibernate statistics</title>
-
- <para>
- If you enable <literal>hibernate.generate_statistics</literal>, Hibernate will
- expose a number of metrics that are useful when tuning a running system via
- <literal>SessionFactory.getStatistics()</literal>. Hibernate can even be configured
- to expose these statistics via JMX. Read the Javadoc of the interfaces in
- <literal>org.hibernate.stats</literal> for more information.
- </para>
-
- </sect2>
- </sect1>
-
- <sect1 id="configuration-logging">
- <title>Logging</title>
-
- <para>
- Hibernate logs various events using Apache commons-logging.
- </para>
-
- <para>
- The commons-logging service will direct output to either Apache Log4j
- (if you include <literal>log4j.jar</literal> in your classpath) or
- JDK1.4 logging (if running under JDK1.4 or above). You may download
- Log4j from <literal>http://jakarta.apache.org</literal>.
- To use Log4j you will need to place a <literal>log4j.properties</literal>
- file in your classpath, an example properties file is distributed with
- Hibernate in the <literal>src/</literal> directory.
- </para>
-
- <para>
- We strongly recommend that you familiarize yourself with Hibernate's log
- messages. A lot of work has been put into making the Hibernate log as
- detailed as possible, without making it unreadable. It is an essential
- troubleshooting device. The most interesting log categories are the
- following:
- </para>
-
- <table frame="topbot" id="log-categories" revision="2">
- <title>Hibernate Log Categories</title>
- <tgroup cols="2">
- <colspec colwidth="1*"/>
- <colspec colwidth="2.5*"/>
- <thead>
- <row>
- <entry>Category</entry>
- <entry>Function</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>org.hibernate.SQL</literal></entry>
- <entry>Log all SQL DML statements as they are executed</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.type</literal></entry>
- <entry>Log all JDBC parameters</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.tool.hbm2ddl</literal></entry>
- <entry>Log all SQL DDL statements as they are executed</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.pretty</literal></entry>
- <entry>
- Log the state of all entities (max 20 entities) associated
- with the session at flush time
- </entry>
- </row>
- <row>
- <entry><literal>org.hibernate.cache</literal></entry>
- <entry>Log all second-level cache activity</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction</literal></entry>
- <entry>Log transaction related activity</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.jdbc</literal></entry>
- <entry>Log all JDBC resource acquisition</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.hql.ast.AST</literal></entry>
- <entry>
- Log HQL and SQL ASTs during query parsing
- </entry>
- </row>
- <row>
- <entry><literal>org.hibernate.secure</literal></entry>
- <entry>Log all JAAS authorization requests</entry>
- </row>
- <row>
- <entry><literal>org.hibernate</literal></entry>
- <entry>
- Log everything (a lot of information, but very useful for
- troubleshooting)
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>
- When developing applications with Hibernate, you should almost always work with
- <literal>debug</literal> enabled for the category <literal>org.hibernate.SQL</literal>,
- or, alternatively, the property <literal>hibernate.show_sql</literal> enabled.
- </para>
-
-
- </sect1>
-
- <sect1 id="configuration-namingstrategy">
- <title>Implementing a <literal>NamingStrategy</literal></title>
-
- <para>
- The interface <literal>org.hibernate.cfg.NamingStrategy</literal> allows you
- to specify a "naming standard" for database objects and schema elements.
- </para>
-
- <para>
- You may provide rules for automatically generating database identifiers from
- Java identifiers or for processing "logical" column and table names given in
- the mapping file into "physical" table and column names. This feature helps
- reduce the verbosity of the mapping document, eliminating repetitive noise
- (<literal>TBL_</literal> prefixes, for example). The default strategy used by
- Hibernate is quite minimal.
- </para>
-
- <para>
- You may specify a different strategy by calling
- <literal>Configuration.setNamingStrategy()</literal> before adding mappings:
- </para>
-
- <programlisting><![CDATA[SessionFactory sf = new Configuration()
- .setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
- .addFile("Item.hbm.xml")
- .addFile("Bid.hbm.xml")
- .buildSessionFactory();]]></programlisting>
-
- <para>
- <literal>org.hibernate.cfg.ImprovedNamingStrategy</literal> is a built-in
- strategy that might be a useful starting point for some applications.
- </para>
-
- </sect1>
-
- <sect1 id="configuration-xmlconfig" revision="2">
- <title>XML configuration file</title>
-
- <para>
- An alternative approach to configuration is to specify a full configuration in
- a file named <literal>hibernate.cfg.xml</literal>. This file can be used as a
- replacement for the <literal>hibernate.properties</literal> file or, if both
- are present, to override properties.
- </para>
-
- <para>
- The XML configuration file is by default expected to be in the root o
- your <literal>CLASSPATH</literal>. Here is an example:
- </para>
-
- <programlisting><![CDATA[<?xml version='1.0' encoding='utf-8'?>
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
-
- <!-- a SessionFactory instance listed as /jndi/name -->
- <session-factory
- name="java:hibernate/SessionFactory">
-
- <!-- properties -->
- <property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
- <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
- <property name="show_sql">false</property>
- <property name="transaction.factory_class">
- org.hibernate.transaction.JTATransactionFactory
- </property>
- <property name="jta.UserTransaction">java:comp/UserTransaction</property>
-
- <!-- mapping files -->
- <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
- <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
-
- <!-- cache settings -->
- <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
- <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
- <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
-
- </session-factory>
-
-</hibernate-configuration>]]></programlisting>
-
- <para>
- As you can see, the advantage of this approach is the externalization of the
- mapping file names to configuration. The <literal>hibernate.cfg.xml</literal>
- is also more convenient once you have to tune the Hibernate cache. Note that is
- your choice to use either <literal>hibernate.properties</literal> or
- <literal>hibernate.cfg.xml</literal>, both are equivalent, except for the above
- mentioned benefits of using the XML syntax.
- </para>
-
- <para>
- With the XML configuration, starting Hibernate is then as simple as
- </para>
-
- <programlisting><![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]></programlisting>
-
- <para>
- You can pick a different XML configuration file using
- </para>
-
- <programlisting><![CDATA[SessionFactory sf = new Configuration()
- .configure("catdb.cfg.xml")
- .buildSessionFactory();]]></programlisting>
-
- </sect1>
-
- <sect1 id="configuration-j2ee" revision="1">
- <title>J2EE Application Server integration</title>
-
- <para>
- Hibernate has the following integration points for J2EE infrastructure:
- </para>
-
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>Container-managed datasources</emphasis>: Hibernate can use
- JDBC connections managed by the container and provided through JNDI. Usually,
- a JTA compatible <literal>TransactionManager</literal> and a
- <literal>ResourceManager</literal> take care of transaction management (CMT),
- esp. distributed transaction handling across several datasources. You may
- of course also demarcate transaction boundaries programmatically (BMT) or
- you might want to use the optional Hibernate <literal>Transaction</literal>
- API for this to keep your code portable.
- </para>
- </listitem>
- </itemizedlist>
-
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>Automatic JNDI binding</emphasis>: Hibernate can bind its
- <literal>SessionFactory</literal> to JNDI after startup.
- </para>
- </listitem>
- </itemizedlist>
-
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>JTA Session binding:</emphasis> The Hibernate <literal>Session</literal>
- may be automatically bound to the scope of JTA transactions. Simply
- lookup the <literal>SessionFactory</literal> from JNDI and get the current
- <literal>Session</literal>. Let Hibernate take care of flushing and closing the
- <literal>Session</literal> when your JTA transaction completes. Transaction
- demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction).
- </para>
- </listitem>
- </itemizedlist>
-
- <itemizedlist>
- <listitem>
- <para>
- <emphasis>JMX deployment:</emphasis> If you have a JMX capable application server
- (e.g. JBoss AS), you can chose to deploy Hibernate as a managed MBean. This saves
- you the one line startup code to build your <literal>SessionFactory</literal> from
- a <literal>Configuration</literal>. The container will startup your
- <literal>HibernateService</literal>, and ideally also take care of service
- dependencies (Datasource has to be available before Hibernate starts, etc).
- </para>
- </listitem>
- </itemizedlist>
-
- <para>
- Depending on your environment, you might have to set the configuration option
- <literal>hibernate.connection.aggressive_release</literal> to true if your
- application server shows "connection containment" exceptions.
- </para>
-
- <sect2 id="configuration-optional-transactionstrategy" revision="3">
- <title>Transaction strategy configuration</title>
-
- <para>
- The Hibernate <literal>Session</literal> API is independent of any transaction
- demarcation system in your architecture. If you let Hibernate use JDBC directly,
- through a connection pool, you may begin and end your transactions by calling
- the JDBC API. If you run in a J2EE application server, you might want to use bean-managed
- transactions and call the JTA API and <literal>UserTransaction</literal> when needed.
- </para>
-
- <para>
- To keep your code portable between these two (and other) environments we recommend the optional
- Hibernate <literal>Transaction</literal> API, which wraps and hides the underlying system.
- You have to specify a factory class for <literal>Transaction</literal> instances by setting the
- Hibernate configuration property <literal>hibernate.transaction.factory_class</literal>.
- </para>
-
- <para>
- There are three standard (built-in) choices:
- </para>
-
- <variablelist spacing="compact">
- <varlistentry>
- <term><literal>org.hibernate.transaction.JDBCTransactionFactory</literal></term>
- <listitem>
- <para>delegates to database (JDBC) transactions (default)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal>org.hibernate.transaction.JTATransactionFactory</literal></term>
- <listitem>
- <para>
- delegates to container-managed transaction if an existing transaction is
- underway in this context (e.g. EJB session bean method), otherwise
- a new transaction is started and bean-managed transaction are used.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal>org.hibernate.transaction.CMTTransactionFactory</literal></term>
- <listitem>
- <para>delegates to container-managed JTA transactions</para>
- </listitem>
- </varlistentry>
- </variablelist>
-
- <para>
- You may also define your own transaction strategies (for a CORBA transaction service,
- for example).
- </para>
-
- <para>
- Some features in Hibernate (i.e. the second level cache, Contextual Sessions with JTA, etc.)
- require access to the JTA <literal>TransactionManager</literal> in a managed environment.
- In an application server you have to specify how Hibernate should obtain a reference to the
- <literal>TransactionManager</literal>, since J2EE does not standardize a single mechanism:
- </para>
-
- <table frame="topbot" id="jtamanagerlookup" revision="1">
- <title>JTA TransactionManagers</title>
- <tgroup cols="2">
- <colspec colwidth="2.5*"/>
- <colspec colwidth="1*"/>
- <thead>
- <row>
- <entry>Transaction Factory</entry>
- <entry align="center">Application Server</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>org.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
- <entry align="center">JBoss</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
- <entry align="center">Weblogic</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
- <entry align="center">WebSphere</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</literal></entry>
- <entry align="center">WebSphere 6</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
- <entry align="center">Orion</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
- <entry align="center">Resin</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
- <entry align="center">JOTM</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
- <entry align="center">JOnAS</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
- <entry align="center">JRun4</entry>
- </row>
- <row>
- <entry><literal>org.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
- <entry align="center">Borland ES</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- </sect2>
-
- <sect2 id="configuration-optional-jndi" revision="3">
- <title>JNDI-bound <literal>SessionFactory</literal></title>
-
- <para>
- A JNDI bound Hibernate <literal>SessionFactory</literal> can simplify the lookup
- of the factory and the creation of new <literal>Session</literal>s. Note that this
- is not related to a JNDI bound <literal>Datasource</literal>, both simply use the
- same registry!
- </para>
-
- <para>
- If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify
- a name (eg. <literal>java:hibernate/SessionFactory</literal>) using the property
- <literal>hibernate.session_factory_name</literal>. If this property is omitted, the
- <literal>SessionFactory</literal> will not be bound to JNDI. (This is especially useful in
- environments with a read-only JNDI default implementation, e.g. Tomcat.)
- </para>
-
- <para>
- When binding the <literal>SessionFactory</literal> to JNDI, Hibernate will use the values of
- <literal>hibernate.jndi.url</literal>, <literal>hibernate.jndi.class</literal> to instantiate
- an initial context. If they are not specified, the default <literal>InitialContext</literal>
- will be used.
- </para>
-
- <para>
- Hibernate will automatically place the <literal>SessionFactory</literal> in JNDI after
- you call <literal>cfg.buildSessionFactory()</literal>. This means you will at least have
- this call in some startup code (or utility class) in your application, unless you use
- JMX deployment with the <literal>HibernateService</literal> (discussed later).
- </para>
-
- <para>
- If you use a JNDI <literal>SessionFactory</literal>, an EJB or any other class may
- obtain the <literal>SessionFactory</literal> using a JNDI lookup.
- </para>
-
- <para>
- We recommend that you bind the <literal>SessionFactory</literal> to JNDI in
- a managed environment and use a <literal>static</literal> singleton otherwise.
- To shield your application code from these details, we also recommend to hide the
- actual lookup code for a <literal>SessionFactory</literal> in a helper class,
- such as <literal>HibernateUtil.getSessionFactory()</literal>. Note that such a
- class is also a convenient way to startup Hibernate—see chapter 1.
- </para>
-
- </sect2>
-
- <sect2 id="configuration-j2ee-currentsession" revision="4">
- <title>Current Session context management with JTA</title>
-
- <para>
- The easiest way to handle <literal>Session</literal>s and transactions is
- Hibernates automatic "current" <literal>Session</literal> management.
- See the discussion of <xref linkend="architecture-current-session">current sessions</xref>.
- Using the <literal>"jta"</literal> session context, if there is no Hibernate
- <literal>Session</literal> associated with the current JTA transaction, one will
- be started and associated with that JTA transaction the first time you call
- <literal>sessionFactory.getCurrentSession()</literal>. The <literal>Session</literal>s
- retrieved via <literal>getCurrentSession()</literal> in <literal>"jta"</literal> context
- will be set to automatically flush before the transaction completes, close
- after the transaction completes, and aggressively release JDBC connections
- after each statement. This allows the <literal>Session</literal>s to
- be managed by the life cycle of the JTA transaction to which it is associated,
- keeping user code clean of such management concerns. Your code can either use
- JTA programmatically through <literal>UserTransaction</literal>, or (recommended
- for portable code) use the Hibernate <literal>Transaction</literal> API to set
- transaction boundaries. If you run in an EJB container, declarative transaction
- demarcation with CMT is preferred.
- </para>
-
- </sect2>
-
- <sect2 id="configuration-j2ee-jmx" revision="1">
- <title>JMX deployment</title>
-
- <para>
- The line <literal>cfg.buildSessionFactory()</literal> still has to be executed
- somewhere to get a <literal>SessionFactory</literal> into JNDI. You can do this
- either in a <literal>static</literal> initializer block (like the one in
- <literal>HibernateUtil</literal>) or you deploy Hibernate as a <emphasis>managed
- service</emphasis>.
- </para>
-
- <para>
- Hibernate is distributed with <literal>org.hibernate.jmx.HibernateService</literal>
- for deployment on an application server with JMX capabilities, such as JBoss AS.
- The actual deployment and configuration is vendor specific. Here is an example
- <literal>jboss-service.xml</literal> for JBoss 4.0.x:
- </para>
-
- <programlisting><![CDATA[<?xml version="1.0"?>
-<server>
-
-<mbean code="org.hibernate.jmx.HibernateService"
- name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
-
- <!-- Required services -->
- <depends>jboss.jca:service=RARDeployer</depends>
- <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
-
- <!-- Bind the Hibernate service to JNDI -->
- <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
-
- <!-- Datasource settings -->
- <attribute name="Datasource">java:HsqlDS</attribute>
- <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
-
- <!-- Transaction integration -->
- <attribute name="TransactionStrategy">
- org.hibernate.transaction.JTATransactionFactory</attribute>
- <attribute name="TransactionManagerLookupStrategy">
- org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
- <attribute name="FlushBeforeCompletionEnabled">true</attribute>
- <attribute name="AutoCloseSessionEnabled">true</attribute>
-
- <!-- Fetching options -->
- <attribute name="MaximumFetchDepth">5</attribute>
-
- <!-- Second-level caching -->
- <attribute name="SecondLevelCacheEnabled">true</attribute>
- <attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
- <attribute name="QueryCacheEnabled">true</attribute>
-
- <!-- Logging -->
- <attribute name="ShowSqlEnabled">true</attribute>
-
- <!-- Mapping files -->
- <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
-
-</mbean>
-
-</server>]]></programlisting>
-
- <para>
- This file is deployed in a directory called <literal>META-INF</literal> and packaged
- in a JAR file with the extension <literal>.sar</literal> (service archive). You also need
- to package Hibernate, its required third-party libraries, your compiled persistent classes,
- as well as your mapping files in the same archive. Your enterprise beans (usually session
- beans) may be kept in their own JAR file, but you may include this EJB JAR file in the
- main service archive to get a single (hot-)deployable unit. Consult the JBoss AS
- documentation for more information about JMX service and EJB deployment.
- </para>
-
- </sect2>
-
- </sect1>
-
-</chapter>
-
+<chapter id="session-configuration" revision="1">
+
+ <title>Configuration</title>
+
+ <para>
+ Because Hibernate is designed to operate in many different environments, there
+ are a large number of configuration parameters. Fortunately, most have sensible
+ default values and Hibernate is distributed with an example
+ <literal>hibernate.properties</literal> file in <literal>etc/</literal> that shows
+ the various options. Just put the example file in your classpath and customize it.
+ </para>
+
+ <sect1 id="configuration-programmatic" revision="1">
+ <title>Programmatic configuration</title>
+
+ <para>
+ An instance of <literal>org.hibernate.cfg.Configuration</literal>
+ represents an entire set of mappings of an application's Java types to an
+ SQL database. The <literal>Configuration</literal> is used to build an
+ (immutable) <literal>SessionFactory</literal>. The mappings are compiled
+ from various XML mapping files.
+ </para>
+
+ <para>
+ You may obtain a <literal>Configuration</literal> instance by instantiating
+ it directly and specifying XML mapping documents. If the mapping files are
+ in the classpath, use <literal>addResource()</literal>:
+ </para>
+
+ <programlisting><![CDATA[Configuration cfg = new Configuration()
+ .addResource("Item.hbm.xml")
+ .addResource("Bid.hbm.xml");]]></programlisting>
+
+ <para>
+ An alternative (sometimes better) way is to specify the mapped class, and
+ let Hibernate find the mapping document for you:
+ </para>
+
+ <programlisting><![CDATA[Configuration cfg = new Configuration()
+ .addClass(org.hibernate.auction.Item.class)
+ .addClass(org.hibernate.auction.Bid.class);]]></programlisting>
+
+ <para>
+ Then Hibernate will look for mapping files named
+ <literal>/org/hibernate/auction/Item.hbm.xml</literal> and
+ <literal>/org/hibernate/auction/Bid.hbm.xml</literal> in the classpath.
+ This approach eliminates any hardcoded filenames.
+ </para>
+
+ <para>
+ A <literal>Configuration</literal> also allows you to specify configuration
+ properties:
+ </para>
+
+ <programlisting><![CDATA[Configuration cfg = new Configuration()
+ .addClass(org.hibernate.auction.Item.class)
+ .addClass(org.hibernate.auction.Bid.class)
+ .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
+ .setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/test")
+ .setProperty("hibernate.order_updates", "true");]]></programlisting>
+
+ <para>
+ This is not the only way to pass configuration properties to Hibernate.
+ The various options include:
+ </para>
+
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>
+ Pass an instance of <literal>java.util.Properties</literal> to
+ <literal>Configuration.setProperties()</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Place <literal>hibernate.properties</literal> in a root directory
+ of the classpath.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Set <literal>System</literal> properties using
+ <literal>java -Dproperty=value</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Include <literal><property></literal> elements in
+ <literal>hibernate.cfg.xml</literal> (discussed later).
+ </para>
+ </listitem>
+ </orderedlist>
+
+ <para>
+ <literal>hibernate.properties</literal> is the easiest approach if you
+ want to get started quickly.
+ </para>
+
+ <para>
+ The <literal>Configuration</literal> is intended as a startup-time object,
+ to be discarded once a <literal>SessionFactory</literal> is created.
+ </para>
+
+ </sect1>
+
+ <sect1 id="configuration-sessionfactory">
+ <title>Obtaining a SessionFactory</title>
+
+ <para>
+ When all mappings have been parsed by the <literal>Configuration</literal>,
+ the application must obtain a factory for <literal>Session</literal> instances.
+ This factory is intended to be shared by all application threads:
+ </para>
+
+ <programlisting><![CDATA[SessionFactory sessions = cfg.buildSessionFactory();]]></programlisting>
+
+ <para>
+ Hibernate does allow your application to instantiate more than one
+ <literal>SessionFactory</literal>. This is useful if you are using more than
+ one database.
+ </para>
+
+ </sect1>
+
+ <sect1 id="configuration-hibernatejdbc" revision="1">
+ <title>JDBC connections</title>
+
+ <para>
+ Usually, you want to have the <literal>SessionFactory</literal> create and pool JDBC
+ connections for you. If you take this approach, opening a <literal>Session</literal>
+ is as simple as:
+ </para>
+
+ <programlisting><![CDATA[Session session = sessions.openSession(); // open a new Session]]></programlisting>
+
+ <para>
+ As soon as you do something that requires access to the database, a JDBC connection
+ will be obtained from the pool.
+ </para>
+
+ <para>
+ For this to work, we need to pass some JDBC connection properties to Hibernate.
+ All Hibernate property names and semantics are defined on the class
+ <literal>org.hibernate.cfg.Environment</literal>. We will now describe the most
+ important settings for JDBC connection configuration.
+ </para>
+
+ <para>
+ Hibernate will obtain (and pool) connections using <literal>java.sql.DriverManager</literal>
+ if you set the following properties:
+ </para>
+
+ <table frame="topbot">
+ <title>Hibernate JDBC Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.connection.driver_class</literal>
+ </entry>
+ <entry>
+ <emphasis>JDBC driver class</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.url</literal>
+ </entry>
+ <entry>
+ <emphasis>JDBC URL</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.username</literal>
+ </entry>
+ <entry>
+ <emphasis>database user</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.password</literal>
+ </entry>
+ <entry>
+ <emphasis>database user password</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.pool_size</literal>
+ </entry>
+ <entry>
+ <emphasis>maximum number of pooled connections</emphasis>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ Hibernate's own connection pooling algorithm is however quite rudimentary.
+ It is intended to help you get started and is <emphasis>not intended for use
+ in a production system</emphasis> or even for performance testing. You should
+ use a third party pool for best performance and stability. Just replace the
+ <literal>hibernate.connection.pool_size</literal> property with connection
+ pool specific settings. This will turn off Hibernate's internal pool. For
+ example, you might like to use C3P0.
+ </para>
+
+ <para>
+ C3P0 is an open source JDBC connection pool distributed along with
+ Hibernate in the <literal>lib</literal> directory. Hibernate will use its
+ <literal>C3P0ConnectionProvider</literal> for connection pooling if you set
+ <literal>hibernate.c3p0.*</literal> properties. If you'd like to use Proxool
+ refer to the packaged <literal>hibernate.properties</literal> and the Hibernate
+ web site for more information.
+ </para>
+
+ <para>
+ Here is an example <literal>hibernate.properties</literal> file for C3P0:
+ </para>
+
+ <programlisting id="c3p0-configuration" revision="1"><![CDATA[hibernate.connection.driver_class = org.postgresql.Driver
+hibernate.connection.url = jdbc:postgresql://localhost/mydatabase
+hibernate.connection.username = myuser
+hibernate.connection.password = secret
+hibernate.c3p0.min_size=5
+hibernate.c3p0.max_size=20
+hibernate.c3p0.timeout=1800
+hibernate.c3p0.max_statements=50
+hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
+
+ <para>
+ For use inside an application server, you should almost always configure
+ Hibernate to obtain connections from an application server
+ <literal>Datasource</literal> registered in JNDI. You'll need to set at
+ least one of the following properties:
+ </para>
+
+ <table frame="topbot">
+ <title>Hibernate Datasource Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.connection.datasource</literal>
+ </entry>
+ <entry>
+ <emphasis>datasource JNDI name</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jndi.url</literal>
+ </entry>
+ <entry>
+ <emphasis>URL of the JNDI provider</emphasis> (optional)
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jndi.class</literal>
+ </entry>
+ <entry>
+ <emphasis>class of the JNDI <literal>InitialContextFactory</literal></emphasis> (optional)
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.username</literal>
+ </entry>
+ <entry>
+ <emphasis>database user</emphasis> (optional)
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.password</literal>
+ </entry>
+ <entry>
+ <emphasis>database user password</emphasis> (optional)
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ Here's an example <literal>hibernate.properties</literal> file for an
+ application server provided JNDI datasource:
+ </para>
+
+ <programlisting><![CDATA[hibernate.connection.datasource = java:/comp/env/jdbc/test
+hibernate.transaction.factory_class = \
+ org.hibernate.transaction.JTATransactionFactory
+hibernate.transaction.manager_lookup_class = \
+ org.hibernate.transaction.JBossTransactionManagerLookup
+hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect]]></programlisting>
+
+ <para>
+ JDBC connections obtained from a JNDI datasource will automatically participate
+ in the container-managed transactions of the application server.
+ </para>
+
+ <para>
+ Arbitrary connection properties may be given by prepending
+ "<literal>hibernate.connection</literal>" to the property name. For example, you
+ may specify a <literal>charSet</literal> using <literal>hibernate.connection.charSet</literal>.
+ </para>
+
+ <para>
+ You may define your own plugin strategy for obtaining JDBC connections by implementing the
+ interface <literal>org.hibernate.connection.ConnectionProvider</literal>. You may select
+ a custom implementation by setting <literal>hibernate.connection.provider_class</literal>.
+ </para>
+
+ </sect1>
+
+ <sect1 id="configuration-optional" revision="1">
+ <title>Optional configuration properties</title>
+
+ <para>
+ There are a number of other properties that control the behaviour of Hibernate
+ at runtime. All are optional and have reasonable default values.
+ </para>
+
+ <para>
+ <emphasis>Warning: some of these properties are "system-level" only.</emphasis>
+ System-level properties can be set only via <literal>java -Dproperty=value</literal> or
+ <literal>hibernate.properties</literal>. They may <emphasis>not</emphasis> be set by
+ the other techniques described above.
+ </para>
+
+ <table frame="topbot" id="configuration-optional-properties" revision="8">
+ <title>Hibernate Configuration Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.dialect</literal>
+ </entry>
+ <entry>
+ The classname of a Hibernate <literal>Dialect</literal> which
+ allows Hibernate to generate SQL optimized for a particular
+ relational database.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>full.classname.of.Dialect</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.show_sql</literal>
+ </entry>
+ <entry>
+ Write all SQL statements to console. This is an alternative
+ to setting the log category <literal>org.hibernate.SQL</literal>
+ to <literal>debug</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.format_sql</literal>
+ </entry>
+ <entry>
+ Pretty print the SQL in the log and console.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.default_schema</literal>
+ </entry>
+ <entry>
+ Qualify unqualified table names with the given schema/tablespace
+ in generated SQL.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>SCHEMA_NAME</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.default_catalog</literal>
+ </entry>
+ <entry>
+ Qualify unqualified table names with the given catalog
+ in generated SQL.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>CATALOG_NAME</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.session_factory_name</literal>
+ </entry>
+ <entry>
+ The <literal>SessionFactory</literal> will be automatically
+ bound to this name in JNDI after it has been created.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>jndi/composite/name</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.max_fetch_depth</literal>
+ </entry>
+ <entry>
+ Set a maximum "depth" for the outer join fetch tree
+ for single-ended associations (one-to-one, many-to-one).
+ A <literal>0</literal> disables default outer join fetching.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ recommended values between <literal>0</literal> and
+ <literal>3</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.default_batch_fetch_size</literal>
+ </entry>
+ <entry>
+ Set a default size for Hibernate batch fetching of associations.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ recommended values <literal>4</literal>, <literal>8</literal>,
+ <literal>16</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.default_entity_mode</literal>
+ </entry>
+ <entry>
+ Set a default mode for entity representation for all sessions
+ opened from this <literal>SessionFactory</literal>
+ <para>
+ <literal>dynamic-map</literal>, <literal>dom4j</literal>,
+ <literal>pojo</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.order_updates</literal>
+ </entry>
+ <entry>
+ Force 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.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.generate_statistics</literal>
+ </entry>
+ <entry>
+ If enabled, Hibernate will collect statistics useful for
+ performance tuning.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.use_identifier_rollback</literal>
+ </entry>
+ <entry>
+ If enabled, generated identifier properties will be
+ reset to default values when objects are deleted.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.use_sql_comments</literal>
+ </entry>
+ <entry>
+ If turned on, Hibernate will generate comments inside the SQL, for
+ easier debugging, defaults to <literal>false</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-jdbc-properties" revision="8">
+ <title>Hibernate JDBC and Connection Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.fetch_size</literal>
+ </entry>
+ <entry>
+ A non-zero value determines the JDBC fetch size (calls
+ <literal>Statement.setFetchSize()</literal>).
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.batch_size</literal>
+ </entry>
+ <entry>
+ A non-zero value enables use of JDBC2 batch updates by Hibernate.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ recommended values between <literal>5</literal> and <literal>30</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.batch_versioned_data</literal>
+ </entry>
+ <entry>
+ Set this property to <literal>true</literal> if your JDBC driver returns
+ correct row counts from <literal>executeBatch()</literal> (it is usually
+ safe to turn this option on). Hibernate will then use batched DML for
+ automatically versioned data. Defaults to <literal>false</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.factory_class</literal>
+ </entry>
+ <entry>
+ Select a custom <literal>Batcher</literal>. Most applications
+ will not need this configuration property.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.BatcherFactory</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.use_scrollable_resultset</literal>
+ </entry>
+ <entry>
+ Enables use of JDBC2 scrollable resultsets by Hibernate.
+ This property is only necessary when using user supplied
+ JDBC connections, Hibernate uses connection metadata otherwise.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.use_streams_for_binary</literal>
+ </entry>
+ <entry>
+ Use streams when writing/reading <literal>binary</literal>
+ or <literal>serializable</literal> types to/from JDBC
+ (system-level property).
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jdbc.use_get_generated_keys</literal>
+ </entry>
+ <entry>
+ Enable use of JDBC3 <literal>PreparedStatement.getGeneratedKeys()</literal>
+ to retrieve natively generated keys after insert. Requires JDBC3+ driver
+ and JRE1.4+, set to false if your driver has problems with the Hibernate
+ identifier generators. By default, tries to determine the driver capabilities
+ using connection metadata.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true|false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.provider_class</literal>
+ </entry>
+ <entry>
+ The classname of a custom <literal>ConnectionProvider</literal> which provides
+ JDBC connections to Hibernate.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.ConnectionProvider</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.isolation</literal>
+ </entry>
+ <entry>
+ Set the JDBC transaction isolation level. Check
+ <literal>java.sql.Connection</literal> for meaningful values but
+ note that most databases do not support all isolation levels.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>1, 2, 4, 8</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.autocommit</literal>
+ </entry>
+ <entry>
+ Enables autocommit for JDBC pooled connections (not recommended).
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.release_mode</literal>
+ </entry>
+ <entry>
+ Specify when Hibernate should release JDBC connections. By default,
+ a JDBC connection is held until the session is explicitly closed or
+ disconnected. For an application server JTA datasource, you should use
+ <literal>after_statement</literal> to aggressively release connections
+ after every JDBC call. For a non-JTA connection, it often makes sense to
+ release the connection at the end of each transaction, by using
+ <literal>after_transaction</literal>. <literal>auto</literal> will
+ choose <literal>after_statement</literal> for the JTA and CMT transaction
+ strategies and <literal>after_transaction</literal> for the JDBC
+ transaction strategy.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>auto</literal> (default) | <literal>on_close</literal> |
+ <literal>after_transaction</literal> | <literal>after_statement</literal>
+ </para>
+ <para>
+ Note that this setting only affects <literal>Session</literal>s returned from
+ <literal>SessionFactory.openSession</literal>. For <literal>Session</literal>s
+ obtained through <literal>SessionFactory.getCurrentSession</literal>, the
+ <literal>CurrentSessionContext</literal> implementation configured for use
+ controls the connection release mode for those <literal>Session</literal>s.
+ See <xref linkend="architecture-current-session"/>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.connection.<emphasis><propertyName></emphasis></literal>
+ </entry>
+ <entry>
+ Pass the JDBC property <literal>propertyName</literal>
+ to <literal>DriverManager.getConnection()</literal>.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.jndi.<emphasis><propertyName></emphasis></literal>
+ </entry>
+ <entry>
+ Pass the property <literal>propertyName</literal> to
+ the JNDI <literal>InitialContextFactory</literal>.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-cache-properties" revision="7">
+ <title>Hibernate Cache Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.cache.provider_class</literal>
+ </entry>
+ <entry>
+ The classname of a custom <literal>CacheProvider</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.CacheProvider</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.use_minimal_puts</literal>
+ </entry>
+ <entry>
+ Optimize 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.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true|false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.use_query_cache</literal>
+ </entry>
+ <entry>
+ Enable the query cache, individual queries still have to be set cachable.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true|false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.use_second_level_cache</literal>
+ </entry>
+ <entry>
+ May be used to completely disable the second level cache, which is enabled
+ by default for classes which specify a <literal><cache></literal>
+ mapping.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true|false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.query_cache_factory</literal>
+ </entry>
+ <entry>
+ The classname of a custom <literal>QueryCache</literal> interface,
+ defaults to the built-in <literal>StandardQueryCache</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.QueryCache</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.region_prefix</literal>
+ </entry>
+ <entry>
+ A prefix to use for second-level cache region names.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>prefix</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cache.use_structured_entries</literal>
+ </entry>
+ <entry>
+ Forces Hibernate to store data in the second-level cache
+ in a more human-friendly format.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true|false</literal>
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-transaction-properties" revision="9">
+ <title>Hibernate Transaction Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.transaction.factory_class</literal>
+ </entry>
+ <entry>
+ The classname of a <literal>TransactionFactory</literal>
+ to use with Hibernate <literal>Transaction</literal> API
+ (defaults to <literal>JDBCTransactionFactory</literal>).
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.TransactionFactory</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>jta.UserTransaction</literal>
+ </entry>
+ <entry>
+ A JNDI name used by <literal>JTATransactionFactory</literal> to
+ obtain the JTA <literal>UserTransaction</literal> from the
+ application server.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>jndi/composite/name</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.transaction.manager_lookup_class</literal>
+ </entry>
+ <entry>
+ The classname of a <literal>TransactionManagerLookup</literal>
+ - required when JVM-level caching is enabled or when using hilo
+ generator in a JTA environment.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>classname.of.TransactionManagerLookup</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.transaction.flush_before_completion</literal>
+ </entry>
+ <entry>
+ 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, see
+ <xref linkend="architecture-current-session"/>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.transaction.auto_close_session</literal>
+ </entry>
+ <entry>
+ If enabled, the session will be automatically closed during the
+ after completion phase of the transaction. Built-in and
+ utomatic session context management is preferred, see
+ <xref linkend="architecture-current-session"/>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="topbot" id="configuration-misc-properties" revision="10">
+ <title>Miscellaneous Properties</title>
+ <tgroup cols="2">
+ <colspec colname="c1" colwidth="1*"/>
+ <colspec colname="c2" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Property name</entry>
+ <entry>Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>hibernate.current_session_context_class</literal>
+ </entry>
+ <entry>
+ Supply a (custom) strategy for the scoping of the "current"
+ <literal>Session</literal>. See
+ <xref linkend="architecture-current-session"/> for more
+ information about the built-in strategies.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>jta</literal> | <literal>thread</literal> |
+ <literal>managed</literal> | <literal>custom.Class</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.query.factory_class</literal>
+ </entry>
+ <entry>
+ Chooses the HQL parser implementation.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>org.hibernate.hql.ast.ASTQueryTranslatorFactory</literal> or
+ <literal>org.hibernate.hql.classic.ClassicQueryTranslatorFactory</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.query.substitutions</literal>
+ </entry>
+ <entry>
+ Mapping from tokens in Hibernate queries to SQL tokens
+ (tokens might be function or literal names, for example).
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.hbm2ddl.auto</literal>
+ </entry>
+ <entry>
+ Automatically validate or export schema DDL to the database
+ when the <literal>SessionFactory</literal> is created. With
+ <literal>create-drop</literal>, the database schema will be
+ dropped when the <literal>SessionFactory</literal> is closed
+ explicitly.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>validate</literal> | <literal>update</literal> |
+ <literal>create</literal> | <literal>create-drop</literal>
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <literal>hibernate.cglib.use_reflection_optimizer</literal>
+ </entry>
+ <entry>
+ Enables use of CGLIB instead of runtime reflection (System-level
+ property). Reflection can sometimes be useful when troubleshooting,
+ note that Hibernate always requires CGLIB even if you turn off the
+ optimizer. You can not set this property in <literal>hibernate.cfg.xml</literal>.
+ <para>
+ <emphasis role="strong">eg.</emphasis>
+ <literal>true</literal> | <literal>false</literal>
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <sect2 id="configuration-optional-dialects" revision="1">
+ <title>SQL Dialects</title>
+
+ <para>
+ You should always set the <literal>hibernate.dialect</literal> property to the correct
+ <literal>org.hibernate.dialect.Dialect</literal> subclass for your database. If you
+ specify a dialect, Hibernate will use sensible defaults for some of the
+ other properties listed above, saving you the effort of specifying them manually.
+ </para>
+
+ <table frame="topbot" id="sql-dialects" revision="2">
+ <title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title>
+ <tgroup cols="2">
+ <colspec colwidth="1*"/>
+ <colspec colwidth="2.5*"/>
+ <thead>
+ <row>
+ <entry>RDBMS</entry>
+ <entry>Dialect</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>DB2</entry> <entry><literal>org.hibernate.dialect.DB2Dialect</literal></entry>
+ </row>
+ <row>
+ <entry>DB2 AS/400</entry> <entry><literal>org.hibernate.dialect.DB2400Dialect</literal></entry>
+ </row>
+ <row>
+ <entry>DB2 OS390</entry> <entry><literal>org.hibernate.dialect.DB2390Dialect</literal></entry>
+ </row>
+ <row>
+ <entry>PostgreSQL</entry> <entry><literal>org.hibernate.dialect.PostgreSQLDialect</literal></entry>
+ </row>
+ <row>
+ <entry>MySQL</entry> <entry><literal>org.hibernate.dialect.MySQLDialect</literal></entry>
+ </row>
+ <row>
+ <entry>MySQL with InnoDB</entry> <entry><literal>org.hibernate.dialect.MySQLInnoDBDialect</literal></entry>
+ </row>
+ <row>
+ <entry>MySQL with MyISAM</entry> <entry><literal>org.hibernate.dialect.MySQLMyISAMDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Oracle (any version)</entry> <entry><literal>org.hibernate.dialect.OracleDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Oracle 9i/10g</entry> <entry><literal>org.hibernate.dialect.Oracle9Dialect</literal></entry>
+ </row>
+ <row>
+ <entry>Sybase</entry> <entry><literal>org.hibernate.dialect.SybaseDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Sybase Anywhere</entry> <entry><literal>org.hibernate.dialect.SybaseAnywhereDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Microsoft SQL Server</entry> <entry><literal>org.hibernate.dialect.SQLServerDialect</literal></entry>
+ </row>
+ <row>
+ <entry>SAP DB</entry> <entry><literal>org.hibernate.dialect.SAPDBDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Informix</entry> <entry><literal>org.hibernate.dialect.InformixDialect</literal></entry>
+ </row>
+ <row>
+ <entry>HypersonicSQL</entry> <entry><literal>org.hibernate.dialect.HSQLDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Ingres</entry> <entry><literal>org.hibernate.dialect.IngresDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Progress</entry> <entry><literal>org.hibernate.dialect.ProgressDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Mckoi SQL</entry> <entry><literal>org.hibernate.dialect.MckoiDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Interbase</entry> <entry><literal>org.hibernate.dialect.InterbaseDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Pointbase</entry> <entry><literal>org.hibernate.dialect.PointbaseDialect</literal></entry>
+ </row>
+ <row>
+ <entry>FrontBase</entry> <entry><literal>org.hibernate.dialect.FrontbaseDialect</literal></entry>
+ </row>
+ <row>
+ <entry>Firebird</entry> <entry><literal>org.hibernate.dialect.FirebirdDialect</literal></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-outerjoin" revision="4">
+ <title>Outer Join Fetching</title>
+
+ <para>
+ If your database supports ANSI, Oracle or Sybase style outer joins, <emphasis>outer join
+ fetching</emphasis> will often increase performance by limiting the number of round
+ trips to and from the database (at the cost of possibly more work performed by
+ the database itself). Outer join fetching allows a whole graph of objects connected
+ by many-to-one, one-to-many, many-to-many and one-to-one associations to be retrieved
+ in a single SQL <literal>SELECT</literal>.
+ </para>
+
+ <para>
+ Outer join fetching may be disabled <emphasis>globally</emphasis> by setting
+ the property <literal>hibernate.max_fetch_depth</literal> to <literal>0</literal>.
+ A setting of <literal>1</literal> or higher enables outer join fetching for
+ one-to-one and many-to-one associations which have been mapped with
+ <literal>fetch="join"</literal>.
+ </para>
+
+ <para>
+ See <xref linkend="performance-fetching"/> for more information.
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-binarystreams" revision="1">
+ <title>Binary Streams</title>
+
+ <para>
+ Oracle limits the size of <literal>byte</literal> arrays that may
+ be passed to/from its JDBC driver. If you wish to use large instances of
+ <literal>binary</literal> or <literal>serializable</literal> type, you should
+ enable <literal>hibernate.jdbc.use_streams_for_binary</literal>.
+ <emphasis>This is a system-level setting only.</emphasis>
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-cacheprovider" revision="2">
+ <title>Second-level and query cache</title>
+
+ <para>
+ The properties prefixed by <literal>hibernate.cache</literal>
+ allow you to use a process or cluster scoped second-level cache system
+ with Hibernate. See the <xref linkend="performance-cache"/> for
+ more details.
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-querysubstitution">
+ <title>Query Language Substitution</title>
+
+ <para>
+ You may define new Hibernate query tokens using <literal>hibernate.query.substitutions</literal>.
+ For example:
+ </para>
+
+ <programlisting>hibernate.query.substitutions true=1, false=0</programlisting>
+
+ <para>
+ would cause the tokens <literal>true</literal> and <literal>false</literal> to be translated to
+ integer literals in the generated SQL.
+ </para>
+
+ <programlisting>hibernate.query.substitutions toLowercase=LOWER</programlisting>
+
+ <para>
+ would allow you to rename the SQL <literal>LOWER</literal> function.
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-statistics" revision="2">
+ <title>Hibernate statistics</title>
+
+ <para>
+ If you enable <literal>hibernate.generate_statistics</literal>, Hibernate will
+ expose a number of metrics that are useful when tuning a running system via
+ <literal>SessionFactory.getStatistics()</literal>. Hibernate can even be configured
+ to expose these statistics via JMX. Read the Javadoc of the interfaces in
+ <literal>org.hibernate.stats</literal> for more information.
+ </para>
+
+ </sect2>
+ </sect1>
+
+ <sect1 id="configuration-logging">
+ <title>Logging</title>
+
+ <para>
+ Hibernate logs various events using Apache commons-logging.
+ </para>
+
+ <para>
+ The commons-logging service will direct output to either Apache Log4j
+ (if you include <literal>log4j.jar</literal> in your classpath) or
+ JDK1.4 logging (if running under JDK1.4 or above). You may download
+ Log4j from <literal>http://jakarta.apache.org</literal>.
+ To use Log4j you will need to place a <literal>log4j.properties</literal>
+ file in your classpath, an example properties file is distributed with
+ Hibernate in the <literal>src/</literal> directory.
+ </para>
+
+ <para>
+ We strongly recommend that you familiarize yourself with Hibernate's log
+ messages. A lot of work has been put into making the Hibernate log as
+ detailed as possible, without making it unreadable. It is an essential
+ troubleshooting device. The most interesting log categories are the
+ following:
+ </para>
+
+ <table frame="topbot" id="log-categories" revision="2">
+ <title>Hibernate Log Categories</title>
+ <tgroup cols="2">
+ <colspec colwidth="1*"/>
+ <colspec colwidth="2.5*"/>
+ <thead>
+ <row>
+ <entry>Category</entry>
+ <entry>Function</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>org.hibernate.SQL</literal></entry>
+ <entry>Log all SQL DML statements as they are executed</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.type</literal></entry>
+ <entry>Log all JDBC parameters</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.tool.hbm2ddl</literal></entry>
+ <entry>Log all SQL DDL statements as they are executed</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.pretty</literal></entry>
+ <entry>
+ Log the state of all entities (max 20 entities) associated
+ with the session at flush time
+ </entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.cache</literal></entry>
+ <entry>Log all second-level cache activity</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction</literal></entry>
+ <entry>Log transaction related activity</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.jdbc</literal></entry>
+ <entry>Log all JDBC resource acquisition</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.hql.ast.AST</literal></entry>
+ <entry>
+ Log HQL and SQL ASTs during query parsing
+ </entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.secure</literal></entry>
+ <entry>Log all JAAS authorization requests</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate</literal></entry>
+ <entry>
+ Log everything (a lot of information, but very useful for
+ troubleshooting)
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ When developing applications with Hibernate, you should almost always work with
+ <literal>debug</literal> enabled for the category <literal>org.hibernate.SQL</literal>,
+ or, alternatively, the property <literal>hibernate.show_sql</literal> enabled.
+ </para>
+
+
+ </sect1>
+
+ <sect1 id="configuration-namingstrategy">
+ <title>Implementing a <literal>NamingStrategy</literal></title>
+
+ <para>
+ The interface <literal>org.hibernate.cfg.NamingStrategy</literal> allows you
+ to specify a "naming standard" for database objects and schema elements.
+ </para>
+
+ <para>
+ You may provide rules for automatically generating database identifiers from
+ Java identifiers or for processing "logical" column and table names given in
+ the mapping file into "physical" table and column names. This feature helps
+ reduce the verbosity of the mapping document, eliminating repetitive noise
+ (<literal>TBL_</literal> prefixes, for example). The default strategy used by
+ Hibernate is quite minimal.
+ </para>
+
+ <para>
+ You may specify a different strategy by calling
+ <literal>Configuration.setNamingStrategy()</literal> before adding mappings:
+ </para>
+
+ <programlisting><![CDATA[SessionFactory sf = new Configuration()
+ .setNamingStrategy(ImprovedNamingStrategy.INSTANCE)
+ .addFile("Item.hbm.xml")
+ .addFile("Bid.hbm.xml")
+ .buildSessionFactory();]]></programlisting>
+
+ <para>
+ <literal>org.hibernate.cfg.ImprovedNamingStrategy</literal> is a built-in
+ strategy that might be a useful starting point for some applications.
+ </para>
+
+ </sect1>
+
+ <sect1 id="configuration-xmlconfig" revision="2">
+ <title>XML configuration file</title>
+
+ <para>
+ An alternative approach to configuration is to specify a full configuration in
+ a file named <literal>hibernate.cfg.xml</literal>. This file can be used as a
+ replacement for the <literal>hibernate.properties</literal> file or, if both
+ are present, to override properties.
+ </para>
+
+ <para>
+ The XML configuration file is by default expected to be in the root of
+ your <literal>CLASSPATH</literal>. Here is an example:
+ </para>
+
+ <programlisting><![CDATA[<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+
+ <!-- a SessionFactory instance listed as /jndi/name -->
+ <session-factory
+ name="java:hibernate/SessionFactory">
+
+ <!-- properties -->
+ <property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
+ <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
+ <property name="show_sql">false</property>
+ <property name="transaction.factory_class">
+ org.hibernate.transaction.JTATransactionFactory
+ </property>
+ <property name="jta.UserTransaction">java:comp/UserTransaction</property>
+
+ <!-- mapping files -->
+ <mapping resource="org/hibernate/auction/Item.hbm.xml"/>
+ <mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
+
+ <!-- cache settings -->
+ <class-cache class="org.hibernate.auction.Item" usage="read-write"/>
+ <class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
+ <collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
+
+ </session-factory>
+
+</hibernate-configuration>]]></programlisting>
+
+ <para>
+ As you can see, the advantage of this approach is the externalization of the
+ mapping file names to configuration. The <literal>hibernate.cfg.xml</literal>
+ is also more convenient once you have to tune the Hibernate cache. Note that it is
+ your choice to use either <literal>hibernate.properties</literal> or
+ <literal>hibernate.cfg.xml</literal>, both are equivalent, except for the above
+ mentioned benefits of using the XML syntax.
+ </para>
+
+ <para>
+ With the XML configuration, starting Hibernate is then as simple as
+ </para>
+
+ <programlisting><![CDATA[SessionFactory sf = new Configuration().configure().buildSessionFactory();]]></programlisting>
+
+ <para>
+ You can pick a different XML configuration file using
+ </para>
+
+ <programlisting><![CDATA[SessionFactory sf = new Configuration()
+ .configure("catdb.cfg.xml")
+ .buildSessionFactory();]]></programlisting>
+
+ </sect1>
+
+ <sect1 id="configuration-j2ee" revision="1">
+ <title>J2EE Application Server integration</title>
+
+ <para>
+ Hibernate has the following integration points for J2EE infrastructure:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>Container-managed datasources</emphasis>: Hibernate can use
+ JDBC connections managed by the container and provided through JNDI. Usually,
+ a JTA compatible <literal>TransactionManager</literal> and a
+ <literal>ResourceManager</literal> take care of transaction management (CMT),
+ esp. distributed transaction handling across several datasources. You may
+ of course also demarcate transaction boundaries programmatically (BMT) or
+ you might want to use the optional Hibernate <literal>Transaction</literal>
+ API for this to keep your code portable.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>Automatic JNDI binding</emphasis>: Hibernate can bind its
+ <literal>SessionFactory</literal> to JNDI after startup.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>JTA Session binding:</emphasis> The Hibernate <literal>Session</literal>
+ may be automatically bound to the scope of JTA transactions. Simply
+ lookup the <literal>SessionFactory</literal> from JNDI and get the current
+ <literal>Session</literal>. Let Hibernate take care of flushing and closing the
+ <literal>Session</literal> when your JTA transaction completes. Transaction
+ demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction).
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis>JMX deployment:</emphasis> If you have a JMX capable application server
+ (e.g. JBoss AS), you can chose to deploy Hibernate as a managed MBean. This saves
+ you the one line startup code to build your <literal>SessionFactory</literal> from
+ a <literal>Configuration</literal>. The container will startup your
+ <literal>HibernateService</literal>, and ideally also take care of service
+ dependencies (Datasource has to be available before Hibernate starts, etc).
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ Depending on your environment, you might have to set the configuration option
+ <literal>hibernate.connection.aggressive_release</literal> to true if your
+ application server shows "connection containment" exceptions.
+ </para>
+
+ <sect2 id="configuration-optional-transactionstrategy" revision="3">
+ <title>Transaction strategy configuration</title>
+
+ <para>
+ The Hibernate <literal>Session</literal> API is independent of any transaction
+ demarcation system in your architecture. If you let Hibernate use JDBC directly,
+ through a connection pool, you may begin and end your transactions by calling
+ the JDBC API. If you run in a J2EE application server, you might want to use bean-managed
+ transactions and call the JTA API and <literal>UserTransaction</literal> when needed.
+ </para>
+
+ <para>
+ To keep your code portable between these two (and other) environments we recommend the optional
+ Hibernate <literal>Transaction</literal> API, which wraps and hides the underlying system.
+ You have to specify a factory class for <literal>Transaction</literal> instances by setting the
+ Hibernate configuration property <literal>hibernate.transaction.factory_class</literal>.
+ </para>
+
+ <para>
+ There are three standard (built-in) choices:
+ </para>
+
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.JDBCTransactionFactory</literal></term>
+ <listitem>
+ <para>delegates to database (JDBC) transactions (default)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.JTATransactionFactory</literal></term>
+ <listitem>
+ <para>
+ delegates to container-managed transaction if an existing transaction is
+ underway in this context (e.g. EJB session bean method), otherwise
+ a new transaction is started and bean-managed transaction are used.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><literal>org.hibernate.transaction.CMTTransactionFactory</literal></term>
+ <listitem>
+ <para>delegates to container-managed JTA transactions</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
+ <para>
+ You may also define your own transaction strategies (for a CORBA transaction service,
+ for example).
+ </para>
+
+ <para>
+ Some features in Hibernate (i.e. the second level cache, Contextual Sessions with JTA, etc.)
+ require access to the JTA <literal>TransactionManager</literal> in a managed environment.
+ In an application server you have to specify how Hibernate should obtain a reference to the
+ <literal>TransactionManager</literal>, since J2EE does not standardize a single mechanism:
+ </para>
+
+ <table frame="topbot" id="jtamanagerlookup" revision="1">
+ <title>JTA TransactionManagers</title>
+ <tgroup cols="2">
+ <colspec colwidth="2.5*"/>
+ <colspec colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Transaction Factory</entry>
+ <entry align="center">Application Server</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>org.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
+ <entry align="center">JBoss</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
+ <entry align="center">Weblogic</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
+ <entry align="center">WebSphere</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</literal></entry>
+ <entry align="center">WebSphere 6</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
+ <entry align="center">Orion</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
+ <entry align="center">Resin</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
+ <entry align="center">JOTM</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
+ <entry align="center">JOnAS</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
+ <entry align="center">JRun4</entry>
+ </row>
+ <row>
+ <entry><literal>org.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
+ <entry align="center">Borland ES</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </sect2>
+
+ <sect2 id="configuration-optional-jndi" revision="3">
+ <title>JNDI-bound <literal>SessionFactory</literal></title>
+
+ <para>
+ A JNDI bound Hibernate <literal>SessionFactory</literal> can simplify the lookup
+ of the factory and the creation of new <literal>Session</literal>s. Note that this
+ is not related to a JNDI bound <literal>Datasource</literal>, both simply use the
+ same registry!
+ </para>
+
+ <para>
+ If you wish to have the <literal>SessionFactory</literal> bound to a JNDI namespace, specify
+ a name (eg. <literal>java:hibernate/SessionFactory</literal>) using the property
+ <literal>hibernate.session_factory_name</literal>. If this property is omitted, the
+ <literal>SessionFactory</literal> will not be bound to JNDI. (This is especially useful in
+ environments with a read-only JNDI default implementation, e.g. Tomcat.)
+ </para>
+
+ <para>
+ When binding the <literal>SessionFactory</literal> to JNDI, Hibernate will use the values of
+ <literal>hibernate.jndi.url</literal>, <literal>hibernate.jndi.class</literal> to instantiate
+ an initial context. If they are not specified, the default <literal>InitialContext</literal>
+ will be used.
+ </para>
+
+ <para>
+ Hibernate will automatically place the <literal>SessionFactory</literal> in JNDI after
+ you call <literal>cfg.buildSessionFactory()</literal>. This means you will at least have
+ this call in some startup code (or utility class) in your application, unless you use
+ JMX deployment with the <literal>HibernateService</literal> (discussed later).
+ </para>
+
+ <para>
+ If you use a JNDI <literal>SessionFactory</literal>, an EJB or any other class may
+ obtain the <literal>SessionFactory</literal> using a JNDI lookup.
+ </para>
+
+ <para>
+ We recommend that you bind the <literal>SessionFactory</literal> to JNDI in
+ a managed environment and use a <literal>static</literal> singleton otherwise.
+ To shield your application code from these details, we also recommend to hide the
+ actual lookup code for a <literal>SessionFactory</literal> in a helper class,
+ such as <literal>HibernateUtil.getSessionFactory()</literal>. Note that such a
+ class is also a convenient way to startup Hibernate—see chapter 1.
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-j2ee-currentsession" revision="4">
+ <title>Current Session context management with JTA</title>
+
+ <para>
+ The easiest way to handle <literal>Session</literal>s and transactions is
+ Hibernates automatic "current" <literal>Session</literal> management.
+ See the discussion of <xref linkend="architecture-current-session">current sessions</xref>.
+ Using the <literal>"jta"</literal> session context, if there is no Hibernate
+ <literal>Session</literal> associated with the current JTA transaction, one will
+ be started and associated with that JTA transaction the first time you call
+ <literal>sessionFactory.getCurrentSession()</literal>. The <literal>Session</literal>s
+ retrieved via <literal>getCurrentSession()</literal> in <literal>"jta"</literal> context
+ will be set to automatically flush before the transaction completes, close
+ after the transaction completes, and aggressively release JDBC connections
+ after each statement. This allows the <literal>Session</literal>s to
+ be managed by the life cycle of the JTA transaction to which it is associated,
+ keeping user code clean of such management concerns. Your code can either use
+ JTA programmatically through <literal>UserTransaction</literal>, or (recommended
+ for portable code) use the Hibernate <literal>Transaction</literal> API to set
+ transaction boundaries. If you run in an EJB container, declarative transaction
+ demarcation with CMT is preferred.
+ </para>
+
+ </sect2>
+
+ <sect2 id="configuration-j2ee-jmx" revision="1">
+ <title>JMX deployment</title>
+
+ <para>
+ The line <literal>cfg.buildSessionFactory()</literal> still has to be executed
+ somewhere to get a <literal>SessionFactory</literal> into JNDI. You can do this
+ either in a <literal>static</literal> initializer block (like the one in
+ <literal>HibernateUtil</literal>) or you deploy Hibernate as a <emphasis>managed
+ service</emphasis>.
+ </para>
+
+ <para>
+ Hibernate is distributed with <literal>org.hibernate.jmx.HibernateService</literal>
+ for deployment on an application server with JMX capabilities, such as JBoss AS.
+ The actual deployment and configuration is vendor specific. Here is an example
+ <literal>jboss-service.xml</literal> for JBoss 4.0.x:
+ </para>
+
+ <programlisting><![CDATA[<?xml version="1.0"?>
+<server>
+
+<mbean code="org.hibernate.jmx.HibernateService"
+ name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
+
+ <!-- Required services -->
+ <depends>jboss.jca:service=RARDeployer</depends>
+ <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
+
+ <!-- Bind the Hibernate service to JNDI -->
+ <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
+
+ <!-- Datasource settings -->
+ <attribute name="Datasource">java:HsqlDS</attribute>
+ <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
+
+ <!-- Transaction integration -->
+ <attribute name="TransactionStrategy">
+ org.hibernate.transaction.JTATransactionFactory</attribute>
+ <attribute name="TransactionManagerLookupStrategy">
+ org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
+ <attribute name="FlushBeforeCompletionEnabled">true</attribute>
+ <attribute name="AutoCloseSessionEnabled">true</attribute>
+
+ <!-- Fetching options -->
+ <attribute name="MaximumFetchDepth">5</attribute>
+
+ <!-- Second-level caching -->
+ <attribute name="SecondLevelCacheEnabled">true</attribute>
+ <attribute name="CacheProviderClass">org.hibernate.cache.EhCacheProvider</attribute>
+ <attribute name="QueryCacheEnabled">true</attribute>
+
+ <!-- Logging -->
+ <attribute name="ShowSqlEnabled">true</attribute>
+
+ <!-- Mapping files -->
+ <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
+
+</mbean>
+
+</server>]]></programlisting>
+
+ <para>
+ This file is deployed in a directory called <literal>META-INF</literal> and packaged
+ in a JAR file with the extension <literal>.sar</literal> (service archive). You also need
+ to package Hibernate, its required third-party libraries, your compiled persistent classes,
+ as well as your mapping files in the same archive. Your enterprise beans (usually session
+ beans) may be kept in their own JAR file, but you may include this EJB JAR file in the
+ main service archive to get a single (hot-)deployable unit. Consult the JBoss AS
+ documentation for more information about JMX service and EJB deployment.
+ </para>
+
+ </sect2>
+
+ </sect1>
+
+</chapter>
+
Modified: core/trunk/documentation/manual/pt-BR/src/main/docbook/modules/configuration.xml
===================================================================
--- core/trunk/documentation/manual/pt-BR/src/main/docbook/modules/configuration.xml 2007-08-13 20:04:19 UTC (rev 12925)
+++ core/trunk/documentation/manual/pt-BR/src/main/docbook/modules/configuration.xml 2007-08-13 20:04:26 UTC (rev 12926)
@@ -1384,7 +1384,7 @@
</para>
<para>
- The XML configuration file is by default expected to be in the root o
+ The XML configuration file is by default expected to be in the root of
your <literal>CLASSPATH</literal>. Here is an example:
O arquivo XML de configuração é por default esperado para estar na
raiz do seu <literal>CLASSPATH</literal>. Veja um exemplo:
17 years, 4 months
Hibernate SVN: r12925 - core/trunk/testsuite.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-08-13 16:04:19 -0400 (Mon, 13 Aug 2007)
New Revision: 12925
Modified:
core/trunk/testsuite/pom.xml
Log:
fixed logging dependencies
Modified: core/trunk/testsuite/pom.xml
===================================================================
--- core/trunk/testsuite/pom.xml 2007-08-12 13:55:13 UTC (rev 12924)
+++ core/trunk/testsuite/pom.xml 2007-08-13 20:04:19 UTC (rev 12925)
@@ -73,6 +73,21 @@
</dependency>
<!-- logging setup for the test suite -->
<dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
@@ -82,6 +97,12 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.5</version>
+ <classifier>jdk15</classifier>
+ </dependency>
</dependencies>
<build>
@@ -101,6 +122,14 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-test-ext-plugin</artifactId>
<version>1.1.0</version>
17 years, 4 months
Hibernate SVN: r12924 - in trunk/HibernateExt/search/doc/reference/en: modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2007-08-12 09:55:13 -0400 (Sun, 12 Aug 2007)
New Revision: 12924
Modified:
trunk/HibernateExt/search/doc/reference/en/master.xml
trunk/HibernateExt/search/doc/reference/en/modules/architecture.xml
trunk/HibernateExt/search/doc/reference/en/modules/batchindex.xml
trunk/HibernateExt/search/doc/reference/en/modules/configuration.xml
trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml
trunk/HibernateExt/search/doc/reference/en/modules/mapping.xml
trunk/HibernateExt/search/doc/reference/en/modules/query.xml
Log:
Documentation updates.
Modified: trunk/HibernateExt/search/doc/reference/en/master.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/master.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/master.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -35,15 +35,16 @@
<para>Full text search engines like <productname>Apache
Lucene</productname> are very powerful technologies to add efficient free
- text queries to applications. However, they suffer several mismatches when
- dealing with object domain models, eg indeces have to be kept up to date,
+ text search capabilities to applications. However, they suffer several mismatches when
+ dealing with object domain models. Amongst other things indexes have to be kept up to date and
mismatches between index structure and domain model as well as query mismatches
have to be avoided. <sbr/>
Hibernate Search indexes your domain model thanks to a few annotations,
- takes care of the database/index synchronization and brings you back
+ takes care of database/index synchronization and brings you back
regular managed objects from free text queries. To achieve this Hibernate Search
- is using <ulink url="http://lucene.apache.org">Apache Lucene</ulink> under the
- cover.</para>
+ is combining the power of <ulink url="http://www.hibernate.org">Hibernate</ulink> and
+ <ulink url="http://lucene.apache.org">Apache Lucene</ulink>.
+ </para>
<important>Hibernate Search is a work in progress and new features are cooking
in this area. So expect some compatibility changes in subsequent
Modified: trunk/HibernateExt/search/doc/reference/en/modules/architecture.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/architecture.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/architecture.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -2,13 +2,15 @@
<!-- $Id$ -->
<chapter id="search-architecture">
<title>Architecture</title>
-
- <para>Hibernate Search is consists of an indexing engine and an index search
+ <section>
+ <title>Overview</title>
+
+ <para>Hibernate Search consists of an indexing and an index search
engine. Both are backed by Apache Lucene.</para>
- <para>When an entity is inserted, updated or removed to/from the database,
+ <para>When an entity is inserted, updated or removed in the database,
Hibernate Search keeps track of this event (through the Hibernate event
- system) and schedule an index update. All the index updates are handled for
+ system) and schedules an index update. All the index updates are handled for
you without you having to use the Apache Lucene APIs
(see <xref linkend="search-configuration-event"/>).
</para>
@@ -28,54 +30,51 @@
or <classname>javax.persistence.Query</classname> APIs exactly the way a
HQL, JPA-QL or native queries would do.</para>
- <section>
- <title>Batching Scope</title>
+ <para>To be more efficient, Hibernate Search batches the write interactions
+ with the Lucene index. There is currently two types of batching depending
+ on the expected scope.</para>
- <para>To be more efficient, Hibernate Search batch the write interactions
- with the Lucene index. There is currently two types of batching depending
- on the expected scope.</para>
+ <para>Outside an transaction, the index update operation is executed
+ right after the actual database operation. This scope is really a no
+ scoping, and no batching is performed.</para>
- <para>When out of transaction, the index update operation is executed
- right after the actual database operation. This scope is really a no
- scoping, and no batching is performed.</para>
+ <para>It is however recommended, for both your database and Hibernate
+ Search, to execute your operation in a transaction be it JDBC or
+ JTA. When in a transaction, the index update operation is scheduled for
+ the transaction commit (and discarded in case of transaction rollback).
+ The batching scope is the transaction. There are two immediate
+ benefits:</para>
- <para>It is however recommended, for both your database and Hibernate
- Search, to execute your operation in a transaction (whether it be JDBC or
- JTA). When in a transaction, the index update operation is schedule for
- the transaction commit (and discarded in case of transaction rollback).
- The batching scope is the transaction. There is 2 immediate
- benefits:</para>
+ <itemizedlist>
+ <listitem>
+ <para>Performance: Lucene indexing works better when operation are
+ executed in batch.</para>
+ </listitem>
- <itemizedlist>
- <listitem>
- <para>performance: Lucene indexing works better when operation are
- executed in batch.</para>
- </listitem>
+ <listitem>
+ <para>ACIDity: The work executed has the same scoping as the one
+ executed by the database transaction and is executed if and only if
+ the transaction is committed.</para>
- <listitem>
- <para>ACIDity: The work executed has the same scoping as the one
- executed by the database transaction and is executed if and only if
- the transaction is committed.</para>
+ <note>
+ <para>Disclaimer, the work in not ACID in the strict sense of it,
+ but ACID behavior is rarely useful for full text search indexes
+ since they can be rebuilt from the source at any time.</para>
+ </note>
+ </listitem>
+ </itemizedlist>
- <note>
- <para>Disclaimer, the work in not ACID in the strict sense of it,
- but ACID behavior is rarely useful for full text search indexes
- since they can be rebuilt from the source at any time.</para>
- </note>
- </listitem>
- </itemizedlist>
+ <para>You can think of those two scopes (no scope vs transactional) as the
+ equivalent of the (infamous) autocommit vs transactional behavior. From a
+ performance perspective, the <emphasis>in transaction</emphasis> mode is
+ recommended. The scoping choice is made transparently: Hibernate Search
+ detects the presence of a transaction and adjust the scoping.</para>
- <para>You can think of those two scopes (no scope vs transactional) as the
- equivalent of the (infamous) autocommit vs transactional behavior. From a
- performance perspective, the <emphasis>in transaction</emphasis> mode is
- recommended. The scoping choice is made transparently: Hibernate Search
- detects the presence of a transaction and adjust the scoping.</para>
+ <note>Hibernate Search works perfectly fine in the Hibernate /
+ EntityManager long conversation pattern aka. atomic conversation.</note>
- <remark>Note that Hibernate Search works perfectly fine in the Hibernate /
- EntityManager long conversation pattern aka. atomic conversation.</remark>
-
- <para>Depending on user demand, additional scoping will be considered, the
- pluggability mechanism being already in place.</para>
+ <note>Depending on user demand, additional scoping will be considered, the
+ pluggability mechanism being already in place.</note>
</section>
<section>
@@ -83,7 +82,7 @@
<para>Hibernate Search offers the ability to let the scoped work being
processed by different back ends. Two back ends are provided out of the
- box for 2 different scenarios.</para>
+ box for two different scenarios.</para>
<section>
<title>Lucene</title>
@@ -91,7 +90,7 @@
<para>In this mode, all index update operations applied on a given node
(JVM) will be executed to the Lucene directories (through the directory
providers) by the same node. This mode is typically used in non
- clustered mode or in clustered mode where the directory store is
+ clustered environment or in clustered environments where the directory store is
shared.</para>
<mediaobject>
@@ -122,10 +121,10 @@
JMS queue. A unique reader will then process the queue and update the
master Lucene index. The master index is then replicated on a regular
basis to the slave copies. This is known as the master / slaves pattern.
- The master is the sole responsible for updating the Lucene index, the
- slaves can accept read/write operations, process the read operation on
- their local index copy, and delegate the update operations to the
- master.</para>
+ The master is the sole responsible for updating the Lucene index. The
+ slaves can accept read as well as write operations. However, they only
+ process the read operation on their local index copy and delegate the update
+ operations to the master.</para>
<mediaobject>
<imageobject role="html">
@@ -145,14 +144,10 @@
the index.</para>
</section>
- <section>
- <title>Custom</title>
-
- <para>Hibernate Search is an extensible architecture. While not yet part
- of the public API, plugging a third party back end is possible. Feel
- free to drop ideas to
- <literal>hibernate-dev(a)lists.jboss.org</literal>.</para>
- </section>
+ <note>Hibernate Search is an extensible architecture. While not yet part
+ of the public API, plugging a third party back end is possible. Feel
+ free to drop ideas to
+ <literal>hibernate-dev(a)lists.jboss.org</literal>.</note>
</section>
<section>
@@ -195,19 +190,11 @@
<para>When executing a query, Hibernate Search interacts with the Apache
Lucene indexes through a reader strategy. chosing a reader strategy will
depend on the profile of the application (frequent updates, read mostly,
- asynchronous index update etc).</para>
+ asynchronous index update etc). See also <xref linkend="configuration-reader-strategy"/></para>
<section>
- <title>not-shared</title>
+ <title>Shared</title>
- <para>Every time a query is executed, a Lucene IndexReader is opened.
- This strategy is not the most efficient: opening and warming up an
- IndexReader can be a relatively expensive operation.</para>
- </section>
-
- <section>
- <title>shared</title>
-
<para>With this strategy, Hibernate Search will share the same
IndexReader, for a given Lucene index, across multiple queries and
threads provided that the IndexReader is still up-to-date. If the
@@ -219,8 +206,16 @@
</section>
<section>
- <title>custom</title>
+ <title>Not-shared</title>
+ <para>Every time a query is executed, a Lucene IndexReader is opened.
+ This strategy is not the most efficient: opening and warming up an
+ IndexReader can be a relatively expensive operation.</para>
+ </section>
+
+ <section>
+ <title>Custom</title>
+
<para>You can write your own reader strategy that suits your application
needs by implementing
<classname>org.hibernate.search.reader.ReaderProvider</classname>. The
Modified: trunk/HibernateExt/search/doc/reference/en/modules/batchindex.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/batchindex.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/batchindex.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -32,7 +32,7 @@
<literal>batch_size</literal> is reached (or if the transaction is
committed), the queue is processed (freeing memory) and emptied. Be aware
that the changes cannot be rollbacked if the number of index elements goes
- beyond <literal>batch_size</literal>. Be also aware that the queue limits is
+ beyond <literal>batch_size</literal>. Be also aware that the queue limits are
also applied on regular transparent indexing (and not only when
<literal>session.index()</literal> is used). That's why a sensitive
<literal>batch_size</literal> value is expected.</para>
Modified: trunk/HibernateExt/search/doc/reference/en/modules/configuration.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/configuration.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/configuration.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -6,10 +6,10 @@
<section id="search-configuration-directory" revision="1">
<title>Directory configuration</title>
- <para>Apache Lucene has a notion of Directory to store the index files.
+ <para>Apache Lucene has a notion of <literal>Directory</literal> to store the index files.
The Directory implementation can be customized, but Lucene comes bundled
- with a file system (<literal>FSDirectoryProvider</literal>) and a full
- memory (RAMDirectoryProvider) implementation. Hibernate Search has the
+ with a file system (<literal>FSDirectoryProvider</literal>) and a in
+ memory (<literal>RAMDirectoryProvider</literal>) implementation. Hibernate Search has the
notion of <literal>DirectoryProvider</literal> that handles the
configuration and the initialization of the Lucene Directory.</para>
@@ -44,7 +44,7 @@
<entry>org.hibernate.search.store.FSMasterDirectoryProvider</entry>
<entry><para>File system based directory. Like
- FSDirectoryProvider. It also copy the index to a source directory
+ FSDirectoryProvider. It also copies the index to a source directory
(aka copy directory) on a regular basis. </para><para>The
recommended value for the refresh period is (at least) 50% higher
that the time to copy the information (default 3600 seconds - 60
@@ -70,7 +70,7 @@
<entry>org.hibernate.search.store.FSSlaveDirectoryProvider</entry>
<entry><para>File system based directory. Like
- FSDirectoryProvider. But retrieve a master version (source) on a
+ FSDirectoryProvider, but retrieves a master version (source) on a
regular basis. To avoid locking and inconsistent search results, 2
local copies are kept. </para><para>The recommended value for the
refresh period is (at least) 50% higher that the time to copy the
@@ -139,12 +139,13 @@
will be indexed, and use an in memory directory named
<literal>Rules</literal> where Rule entities will be indexed.</para>
- <para>So you can easily defined common rules like the directory provider
+ <para>You can easily define common rules like the directory provider
and base directory, and overide those default later on on a per index
basis.</para>
<para>Writing your own <classname>DirectoryProvider</classname>, you can
- benefit this configuration mechanism too.</para>
+ utilize this configuration mechanism as well.</para>
+ </section>
<section id="search-configuration-directory-sharding" revision="1">
<title>Index sharding</title>
@@ -152,9 +153,9 @@
<para>In some extreme cases involving huge indexes (in size), it is
necessary to split (shard) the indexing data of a given entity type into
several Lucene indexes. This solution is not recommended until you reach
- significant index sizes and important indexing slows down, the main
- drawback being that search will end up being slower (more files to
- open). In other words don't do it until you have problems :)</para>
+ significant index sizes and important index updates are slowing down. The main
+ drawback of index sharding is that searches will end up being slower since more files have to
+ be opend for a single search. In other words don't do it until you have problems :)</para>
<para>Despite this strong warning, Hibernate Search allows you to index
a given entity type into several sub indexes. Data is sharded into the
@@ -223,113 +224,107 @@
indexBase, default indexName)</para>
</listitem>
</itemizedlist>
- </section>
</section>
<section>
- <title>Worker and Back ends configuration</title>
+ <title>Worker configuration</title>
<para>Hibernate Search works done by a worker you can configure. The
default (and only) worker today use transactional scoping.</para>
- <section>
- <title>Generic configuration</title>
+ <para>You can define the worker configuration using the following
+ properties</para>
- <para>You can define the worker configuration using the following
- properties</para>
+ <table>
+ <title>worker configuration</title>
- <para></para>
+ <tgroup cols="2">
+ <colspec align="center" />
- <table>
- <title>worker configuration</title>
+ <tbody>
+ <row>
+ <entry>Property</entry>
- <tgroup cols="2">
- <colspec align="center" />
+ <entry>Description</entry>
+ </row>
- <tbody>
- <row>
- <entry>Property</entry>
+ <row>
+ <entry><literal>org.hibernate.worker.backend</literal></entry>
- <entry>Description</entry>
- </row>
+ <entry>Out of the box support for the Apache Lucene back end and
+ the JMS back end. Default to <literal>lucene</literal>. Supports
+ also <literal>jms</literal>.</entry>
+ </row>
- <row>
- <entry><literal>org.hibernate.worker.backend</literal></entry>
+ <row>
+ <entry><literal>org.hibernate.worker.execution</literal></entry>
- <entry>Out of the box support for the Apache Lucene back end and
- the JMS back end. Default to <literal>lucene</literal>. Supports
- also <literal>jms</literal>.</entry>
- </row>
+ <entry>Supports synchronous and asynchrounous execution. Default
+ to <literal><literal>sync</literal></literal>. Supports also
+ <literal>async</literal>.</entry>
+ </row>
- <row>
- <entry><literal>org.hibernate.worker.execution</literal></entry>
+ <row>
+ <entry><literal>org.hibernate.worker.thread_pool.size</literal></entry>
- <entry>Supports synchronous and asynchrounous execution. Default
- to <literal><literal>sync</literal></literal>. Supports also
- <literal>async</literal>.</entry>
- </row>
+ <entry>Defines the number of threads in the pool. useful only
+ for asynchrounous execution. Default to 1.</entry>
+ </row>
- <row>
- <entry><literal>org.hibernate.worker.thread_pool.size</literal></entry>
+ <row>
+ <entry><literal>org.hibernate.worker.buffer_queue.max</literal></entry>
- <entry>Defines the number of threads in the pool. useful only
- for asynchrounous execution. Default to 1.</entry>
- </row>
+ <entry>Defines the maximal number of work queue if the thread
+ poll is starved. Useful only for asynchrounous execution.
+ Default to infinite. If the limit is reached, the work is done
+ by the main thread.</entry>
+ </row>
- <row>
- <entry><literal>org.hibernate.worker.buffer_queue.max</literal></entry>
+ <row>
+ <entry><literal>org.hibernate.worker.jndi.*</literal></entry>
- <entry>Defines the maximal number of work queue if the thread
- poll is starved. Useful only for asynchrounous execution.
- Default to infinite. If the limit is reached, the work is done
- by the main thread.</entry>
- </row>
+ <entry>Defines the JNDI properties to initiate the
+ InitialContext (if needed). JNDI is only used by the JMS back
+ end.</entry>
+ </row>
- <row>
- <entry><literal>org.hibernate.worker.jndi.*</literal></entry>
+ <row>
+ <entry><literal>
+ org.hibernate.worker.jms.connection_factory</literal></entry>
- <entry>Defines the JNDI properties to initiate the
- InitialContext (if needed). JNDI is only used by the JMS back
- end.</entry>
- </row>
+ <entry>Mandatory for the JMS back end. Defines the JNDI name to
+ lookup the JMS connection factory from
+ (<literal>java:/ConnectionFactory</literal> by default in JBoss
+ AS)</entry>
+ </row>
- <row>
- <entry><literal>
- org.hibernate.worker.jms.connection_factory</literal></entry>
+ <row>
+ <entry><literal>
+ org.hibernate.worker.jms.queue</literal></entry>
- <entry>Mandatory for the JMS back end. Defines the JNDI name to
- lookup the JMS connection factory from
- (<literal>java:/ConnectionFactory</literal> by default in JBoss
- AS)</entry>
- </row>
+ <entry>Mandatory for the JMS back end. Defines the JNDI name to
+ lookup the JMS queue from. The queue will be used to post work
+ messages.</entry>
+ </row>
- <row>
- <entry><literal>
- org.hibernate.worker.jms.queue</literal></entry>
+ <row>
+ <entry><literal>
+ org.hibernate.worker.batch_size</literal></entry>
- <entry>Mandatory for the JMS back end. Defines the JNDI name to
- lookup the JMS queue from. The queue will be used to post work
- messages.</entry>
- </row>
+ <entry>Defines the maximum number of elements indexed before
+ flushing the transaction-bound queue. Default to 0 (ie no
+ limit). See <xref linkend="search-batchindex" /> for more
+ information.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
- <row>
- <entry><literal>
- org.hibernate.worker.batch_size</literal></entry>
-
- <entry>Defines the maximum number of elements indexed before
- flushing the transaction-bound queue. Default to 0 (ie no
- limit). See <xref linkend="search-batchindex" /> for more
- information.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
<section id="jms-backend">
<title>JMS Master/Slave configuration</title>
- <para>This chapter describes in greater detail how to configure the
+ <para>This section describes in greater detail how to configure the
Master / Slaves Hibernate Search architecture.</para>
<section>
@@ -374,7 +369,7 @@
<section>
<title>Master node</title>
- <para>Every index update operation is taken fron a JMS queue and
+ <para>Every index update operation is taken from a JMS queue and
executed. The master index(es) is(are) copied on a regular
basis.</para>
@@ -423,26 +418,25 @@
<para>This example inherit the abstract JMS controller class available
and implements a JavaEE 5 MDB. This implementation is given as an
- example and, while most likely ;ore complex, can be adjusted to make
+ example and, while most likely more complex, can be adjusted to make
use of non Java EE Message Driven Beans. For more information about
the <methodname>getSession()</methodname> and
<methodname>cleanSessionIfNeeded()</methodname>, please check
<classname>AbstractJMSHibernateSearchController</classname>'s
javadoc.</para>
- <remark>Hibernate Search test suite makes use of JBoss Embedded to
+ <note>Hibernate Search test suite makes use of JBoss Embedded to
test the JMS integration. It allows the unit test to run both the MDB
container and JBoss Messaging (JMS provider) in a standalone way
- (marketed by some as "lightweight").</remark>
- </section>
+ (marketed by some as "lightweight").</note>
</section>
</section>
- <section>
+ <section id="configuration-reader-strategy">
<title>Reader strategy configuration</title>
<para>The different reader strategies are described in <xref
- linkend="search-architecture-readerstrategy" /> .The default reader
+ linkend="search-architecture-readerstrategy" />. The default reader
strategy is <literal>shared</literal>. This can be adjusted:</para>
<programlisting>hibernate.search.reader.strategy = not-shared</programlisting>
@@ -459,9 +453,9 @@
</section>
<section id="search-configuration-event" revision="2">
- <title>Enabling automatic indexing</title>
+ <title>Automatic indexing</title>
- <para>Automatic indexing is enable out of the box when using Hibernate
+ <para>Automatic indexing is enabled out of the box when using Hibernate
Annotations or Hibernate EntityManager. If, for some reason you need to
disable that, set
<literal>hibernate.search.autoregister_listeners</literal> to false. Note
@@ -518,18 +512,31 @@
<para>There are two sets of parameters allowing for different performance
settings depending on the use case. During indexing operations triggered
- by database modifications
- <literal>hibernate.search.[default|<indexname>].transaction.merge_factor</literal>,
- <literal>hibernate.search.[default|<indexname>].transaction.max_merge_docs</literal>
- and
- <literal>hibernate.search.[default|<indexname>].transaction.max_buffered_docs</literal>
- are used. The corresponding
- <literal>hibernate.search.[default|<indexname>].batch.merge_factor</literal>,
- <literal>hibernate.search.[default|<indexname>].batch.max_merge_docs</literal>
- and
- <literal>hibernate.search.[default|<indexname>].batch.max_buffered_docs</literal>
- properties are applied when indexing occurs via
- <literal>FullTextSession.index()</literal> (see <xref
+ by database modifications:
+ <itemizedlist>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].transaction.merge_factor</literal>
+ </listitem>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].transaction.max_merge_docs</literal>
+ </listitem>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].transaction.max_buffered_docs</literal>
+ </listitem>
+ </itemizedlist>
+ are used. The corresponding properties:
+ <itemizedlist>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].batch.merge_factor</literal>
+ </listitem>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].batch.max_merge_docs</literal>
+ </listitem>
+ <listitem>
+ <literal>hibernate.search.[default|<indexname>].batch.max_buffered_docs</literal>
+ </listitem>
+ </itemizedlist>
+ are applied when indexing occurs via <literal>FullTextSession.index()</literal> (see <xref
linkend="search-batchindex" />).</para>
<para>Unless the corresponding <literal>.batch</literal> property is
Modified: trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -28,23 +28,25 @@
<row>
<entry>Hibernate Search</entry>
<entry>
- Version 3.0.0.Beta4 with all its dependencies - hibernate-search.jar, lucene-core-2.2.0.jar, jms.jar, ejb3-persistence.jar and
- hibernate-commons-annotations.jar
+ <literal>hibernate-search.jar</literal> and all the dependencies from
+ the <literal>lib</literal> directory of the distribution.
</entry>
</row>
<row>
<entry>Hibernate Core</entry>
<entry>
- Version >= 3.2.2 with all its dependencies - hibernate3.jar, ehcache-1.2.3.jar,
- swarmcache-1.0rc2.jar, jboss-cache.jar, jgroups-2.2.8.jar, jta.jar, commons-logging-1.0.4.jar,
- c3p0-0.9.1.jar, asm-attrs.jar, dom4j-1.6.1.jar, ant-antlr-1.6.5.jar, cglib-2.1.3.jar,
- oscache-2.1.jar, asm.jar, commons-collections-2.1.1.jar, ant-1.6.5.jar and proxool-0.8.3.jar.
+ This instructions have been tested against Hibernate 3.2.x. Next to the main
+ <literal>hibernate3.jar</literal> you will need all required libaries from the <literal>lib</literal>
+ directory of the distribution. Refer to <literal>README.txt</literal> in the <literal>lib</literal>
+ directory of the distibution to determine the minimum runtime requirements.
</entry>
</row>
<row>
<entry>Hibernate Annotations</entry>
<entry>
- Version 3.3.x with all its dependencies - hibernate-annotations.jar, ejb3-persistence.jar and jta.jar.
+ Even though Hibernate Search can be used without Hibernate Annotations
+ the following instructions will use them for ease of use. The tutorial is
+ tested against version 3.3.x of Hibernate Annotations.
</entry>
</row>
</tbody>
@@ -62,9 +64,8 @@
<title>Configuration</title>
<para>
Once you have downloaded and added all required dependencies to your application you have
- to add a few properties to your hibernate configuration file. The good
- news is that for initial experiments most properties offer a sensible default and can
- be kept untouched.
+ to add a few properties to your hibernate configuration file (hibernate.properties, hibernate.cfg.xml or persistence.xml). The good news is that for standard use
+ most properties offer a sensible default.
We recommend to start with a <classname>FSDirectoryProvider</classname>.
This has the advantage that you can physically inspect (eg via
<ulink url="http://www.getopt.org/luke/">Luke</ulink>) the Lucene indeces created by
@@ -161,7 +162,7 @@
</section>
<section>
- <title>Inital Indexing</title>
+ <title>Indexing</title>
<para>
Once you have added the above properties and annotations it is time to trigger an
initial batch index of your books. You can achieve this by adding the following lines
@@ -183,7 +184,7 @@
</section>
<section>
- <title>First search</title>
+ <title>Searching</title>
<para>
Now it is time to execute a first search. The following code will prepare a query against
the fields <literal>summary</literal> and <literal>body</literal> , execute it and return
@@ -191,14 +192,19 @@
</para>
<programlisting>
-// get hold of the hibernate session. There are multiple ways of doing this depending on the type of application
-Session session = HibernateUtil.getCurrentSession();
-FullTextSession s = Search.createFullTextSession();
-Transaction tx = s.beginTransaction();
+// JPA users have to use <classname>EntityManager</classname> and <classname>FullTextEntityManager</classname>
+// instead of <classname>Session</classname> and <classname>FullTextSession</classname> in order create a query - see <xref linkend="search-query"/>
-MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{"summary", "body"}, new StandardAnalyzer());
+// the use of HibernateUtil is only an example of how to get hold of the current session!
+Session session = HibernateUtil.getCurrentSession();
+FullTextSession fullTextSession = Search.createFullTextSession();
+
+Transaction tx = fullTextSession.beginTransaction();
+
+MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{"summary", "body"},
+ new StandardAnalyzer());
Query query = parser.parse( "Java" );
-org.hibernate.Query hibQuery = s.createFullTextQuery( query, Book.class );
+org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery( query, Book.class );
List result = hibQuery.list();
tx.commit();
Modified: trunk/HibernateExt/search/doc/reference/en/modules/mapping.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/mapping.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/mapping.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -3,7 +3,7 @@
<chapter id="search-mapping" revision="3">
<title>Mapping entities to the index structure</title>
- <para>All the metadata information related to indexed entities is described
+ <para>All the metadata information needed to index entities is described
through some Java annotations. There is no need for xml mapping files nor a
list of indexed entities. The list is discovered at startup time scanning
the Hibernate mapped entities.</para>
@@ -51,7 +51,7 @@
<para><literal>store</literal> : describe whether or not the
property is stored in the Lucene index. You can store the value
<literal>Store.YES</literal> (comsuming more space in the index but
- allowing projection, see <xref linkend="search-query" /> for more
+ allowing projection, see <xref linkend="projections" /> for more
information), store it in a compressed way
<literal>Store.COMPRESS</literal> (this does consume more CPU), or
avoid any storage <literal>Store.NO</literal> (this is the default
@@ -78,7 +78,7 @@
<para>Whether or not you want to store the data depends on how you wish
to use the index query result. For a regular Hibernate Search usage,
storing is not necessary. However you might want to store some fields to
- subsequently project them (see <xref linkend="search-query" /> for more
+ subsequently project them (see <xref linkend="projections" /> for more
information).</para>
<para>Whether or not you want to tokenize a property depends on whether
@@ -125,10 +125,10 @@
<section>
<title>Mapping properties multiple times</title>
- <para>It is sometimes needed to map a proeprty multiple times per index,
+ <para>It is sometimes needed to map a property multiple times per index,
with slightly different indexing strategies. Especially, sorting a query
by field requires the field to be <literal>UN_TOKENIZED</literal>. If
- one want to search by words in this proeprty and still sort it, one need
+ one want to search by words in this property and still sort it, one need
to index it twice, once tokenized, once untokenized. @Fields allows to
achieve this goal.</para>
@@ -309,7 +309,7 @@
contains a cyclic dependency of classes (not instances). For example, if
<classname>Owner</classname> points to <classname>Place</classname>.
Hibernate Search will stop including Indexed embedded atttributes after
- reaching the expected depth (or is the object graph boundaries are
+ reaching the expected depth (or the object graph boundaries are
reached). A class having a self reference is an example of cyclic
dependency. In our example, because <literal>depth</literal> is set to
1, any <literal>@IndexedEmbedded</literal> attribute in Owner (if any)
@@ -455,10 +455,11 @@
<section id="search-mapping-bridge">
<title>Property/Field Bridge</title>
- <para>All field of a full text index in Lucene have to be represented as
- Strings. Ones Java properties have to be indexed in a String form. For
+ <para>In Lucene all index fields have to be represented as
+ Strings. For this reason all entity properties annotated with <literal>@Field</literal>
+ have to be indexed in a String form. For
most of your properties, Hibernate Search does the translation job for you
- thanks to a built-in set of bridges. In some cases, though you need a fine
+ thanks to a built-in set of bridges. In some cases, though you need a more fine
grain control over the translation process.</para>
<section>
@@ -497,7 +498,7 @@
<para>Numbers are converted in their String representation. Note
that numbers cannot be compared by Lucene (ie used in ranged
queries) out of the box: they have to be padded <footnote>
- <para>Using a Range query is debattable and has drawbacks, an
+ <para>Using a Range query is debatable and has drawbacks, an
alternative approach is to use a Filter query which will
filter the result query to the appropriate range.</para>
@@ -546,9 +547,10 @@
<section>
<title>Custom Bridge</title>
- <para>It can happen that the built-in bridges of Hibernate Search does
+ <para>It can happen that the built-in bridges of Hibernate Search do
not cover some of your property types, or that the String representation
- used is not what you expect.</para>
+ used is not what you expect. The following paragraphs sveral solutions for this
+ problem.</para>
<section>
<title>StringBridge</title>
Modified: trunk/HibernateExt/search/doc/reference/en/modules/query.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/query.xml 2007-08-11 06:48:08 UTC (rev 12923)
+++ trunk/HibernateExt/search/doc/reference/en/modules/query.xml 2007-08-12 13:55:13 UTC (rev 12924)
@@ -30,7 +30,7 @@
List result = fullTextQuery.list(); //return a list of managed objects </programlisting>
<para>The Hibernate query built on top of the Lucene query is a regular
- <literal>org.hibernate.Query</literal> , you are is the same paradigm as the
+ <literal>org.hibernate.Query</literal> , you are in the same paradigm as the
other Hibernate query facilities (HQL, Native or Criteria). The regular
<literal>list()</literal> , <literal>uniqueResult()</literal> ,
<literal>iterate()</literal> and <literal>scroll()</literal> can be
@@ -59,7 +59,7 @@
<section>
<title>Building queries</title>
- <para>Hibernate Search queries are built on top of a Lucene query. It
+ <para>Hibernate Search queries are built on top of Lucene queries. It
gives you a total freedom on the kind of Lucene queries you are willing to
execute. However, once built, Hibernate Search abstract the query
processing from your application using org.hibernate.Query as your primary
@@ -85,7 +85,7 @@
<programlisting>FullTextSession fullTextSession = Search.createFullTextSession( session );
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery );</programlisting>
- <para>If not specified, the query will be executed all indexed,
+ <para>If not specified otherwise, the query will be executed against all indexed entities,
potentially returning all types of indexed classes. It is advised,
from a performance point of view, to restrict the returned
types:</para>
@@ -498,7 +498,7 @@
implementation to each of the parameters equals and hashcode
methods.</para>
- <para>Should filters be cached? There are 2 area where filter caching
+ <para>Why should filters be cached? There are two area where filter caching
shines:</para>
<itemizedlist>
17 years, 4 months
Hibernate SVN: r12923 - trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-11 02:48:08 -0400 (Sat, 11 Aug 2007)
New Revision: 12923
Added:
trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/Cat.java
trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/HEMAutoWireringTest.java
trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/NoOpListener.java
Log:
Remove dependency in tests from em -> validator: move wiring tests into validator project
Added: trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/Cat.java
===================================================================
--- trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/Cat.java (rev 0)
+++ trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/Cat.java 2007-08-11 06:48:08 UTC (rev 12923)
@@ -0,0 +1,48 @@
+//$Id$
+package org.hibernate.validator.test.jpa;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.Min;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Cat implements Serializable {
+ private Integer id;
+ private String name;
+ private long length;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Length(min = 4)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Min(0)
+ public long getLength() {
+ return length;
+ }
+
+ public void setLength(long length) {
+ this.length = length;
+ }
+}
\ No newline at end of file
Added: trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/HEMAutoWireringTest.java
===================================================================
--- trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/HEMAutoWireringTest.java (rev 0)
+++ trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/HEMAutoWireringTest.java 2007-08-11 06:48:08 UTC (rev 12923)
@@ -0,0 +1,54 @@
+//$Id$
+package org.hibernate.validator.test.jpa;
+
+import java.util.Date;
+import java.util.Map;
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.HibernatePersistence;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.validator.InvalidStateException;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class HEMAutoWireringTest extends JPATestCase {
+ public void testPropertyValidation() throws Exception {
+ EntityManager em = factory.createEntityManager();
+ Cat cat = new Cat();
+ cat.setName( "iti" );
+ em.getTransaction().begin();
+ try {
+ em.persist( cat );
+ em.flush();
+ fail( "No validation" );
+ }
+ catch (InvalidStateException e) {
+ //success
+ }
+ finally {
+ em.getTransaction().rollback();
+ em.close();
+ }
+ }
+
+ public void testEventPerProperties() throws Exception {
+ EntityManager em = factory.createEntityManager();
+ assertEquals( "Only validator and explicit NoOp should be present", 2,
+ ( (SessionImplementor) em.getDelegate() ).getListeners().getPreInsertEventListeners().length );
+ em.close();
+ }
+
+ public Class[] getAnnotatedClasses() {
+ return new Class[] {
+ Cat.class
+ };
+ }
+
+
+ public Map getConfig() {
+ Map config = super.getConfig();
+ config.put( HibernatePersistence.EVENT_LISTENER_PREFIX + ".pre-insert", NoOpListener.class.getName() );
+ return config;
+ }
+}
Added: trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/NoOpListener.java
===================================================================
--- trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/NoOpListener.java (rev 0)
+++ trunk/HibernateExt/validator/src/test/org/hibernate/validator/test/jpa/NoOpListener.java 2007-08-11 06:48:08 UTC (rev 12923)
@@ -0,0 +1,14 @@
+//$Id$
+package org.hibernate.validator.test.jpa;
+
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.PreInsertEvent;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class NoOpListener implements PreInsertEventListener {
+ public boolean onPreInsert(PreInsertEvent event) {
+ return false;
+ }
+}
17 years, 4 months
Hibernate SVN: r12922 - in trunk/HibernateExt/entitymanager: src/java/org/hibernate/ejb and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-11 02:47:32 -0400 (Sat, 11 Aug 2007)
New Revision: 12922
Removed:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java
Modified:
trunk/HibernateExt/entitymanager/build.properties.dist
trunk/HibernateExt/entitymanager/build.xml
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
Log:
Remove dependency in tests from em -> validator
Modified: trunk/HibernateExt/entitymanager/build.properties.dist
===================================================================
--- trunk/HibernateExt/entitymanager/build.properties.dist 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/build.properties.dist 2007-08-11 06:47:32 UTC (rev 12922)
@@ -8,6 +8,5 @@
#locally present jars
jpa-api.jar=./lib/ejb3-persistence.jar
-validator.jar=./lib/hibernate-validator.jar
commons-annotations.jar=./lib/hibernate-commons-annotations.jar
annotations.jar=./lib/hibernate-annotations.jar
\ No newline at end of file
Modified: trunk/HibernateExt/entitymanager/build.xml
===================================================================
--- trunk/HibernateExt/entitymanager/build.xml 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/build.xml 2007-08-11 06:47:32 UTC (rev 12922)
@@ -28,8 +28,6 @@
<property name="jpa-api.jar" value="${basedir}/../jpa-api/build/ejb3-persistence.jar"/>
<property name="annotations.jar"
value="${basedir}/../annotations/target/hibernate-annotations/hibernate-annotations.jar"/>
- <property name="validator.jar"
- value="${basedir}/../validator/target/hibernate-validator/hibernate-validator.jar"/>
<property name="commons-annotations.jar"
value="${basedir}/../commons-annotations/target/hibernate-commons-annotations/hibernate-commons-annotations.jar"/>
@@ -46,7 +44,6 @@
<pathelement location="${jpa-api.jar}"/>
<pathelement location="${commons-annotations.jar}"/>
<pathelement location="${annotations.jar}"/>
- <pathelement location="${validator.jar}"/>
</path>
<path id="junit.moduleclasspath">
<pathelement location="${src.dir}"/>
@@ -67,7 +64,6 @@
<available file="${jpa-api.jar}" type="file" property="jpa-api.jar.available"/>
<available file="${commons-annotations.jar}" type="file" property="commons-annotations.jar.available"/>
<available file="${annotations.jar}" type="file" property="annotations.jar.available"/>
- <available file="${validator.jar}" type="file" property="validator.jar.available"/>
<mkdir dir="${lib.dir}/test"/>
</target>
@@ -86,12 +82,7 @@
<ant inheritall="false" dir="${basedir}/../annotations" target="jar"/>
</target>
- <target name="get.validator" depends="init" unless="validator.jar.available">
- <ant inheritall="false" dir="${basedir}/../validator" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../validator" target="jar"/>
- </target>
-
- <target name="compile" depends="init,get.jpa-api,get.commons-annotations,get.annotations,get.validator" description="Compile the Java source code">
+ <target name="compile" depends="init,get.jpa-api,get.commons-annotations,get.annotations" description="Compile the Java source code">
<available
classname="org.eclipse.core.launcher.Main"
property="build.compiler"
@@ -334,7 +325,6 @@
<fileset file="${jpa-api.jar}"/>
<fileset file="${commons-annotations.jar}"/>
<fileset file="${annotations.jar}"/>
- <fileset file="${validator.jar}"/>
</copy>
<mkdir dir="${dist.lib.dir}/test"/>
Modified: trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/EventListenerConfigurator.java 2007-08-11 06:47:32 UTC (rev 12922)
@@ -14,6 +14,7 @@
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.ejb.event.CallbackHandlerConsumer;
import org.hibernate.ejb.event.EJB3AutoFlushEventListener;
import org.hibernate.ejb.event.EJB3DeleteEventListener;
@@ -46,13 +47,11 @@
import org.hibernate.event.PreUpdateEventListener;
import org.hibernate.event.SaveOrUpdateEventListener;
import org.hibernate.mapping.PersistentClass;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.secure.JACCPreDeleteEventListener;
import org.hibernate.secure.JACCPreInsertEventListener;
import org.hibernate.secure.JACCPreLoadEventListener;
import org.hibernate.secure.JACCPreUpdateEventListener;
import org.hibernate.secure.JACCSecurityListener;
-import org.hibernate.validator.event.ValidateEventListener;
/**
* @author Emmanuel Bernard
@@ -69,57 +68,57 @@
//Action event
//EJB3-specific ops listeners
- listenerConfig.setFlushEventListeners( new FlushEventListener[]{EJB3FlushEventListener.INSTANCE} );
+ listenerConfig.setFlushEventListeners( new FlushEventListener[] { EJB3FlushEventListener.INSTANCE } );
//EJB3-specific ops listeners
- listenerConfig.setAutoFlushEventListeners( new AutoFlushEventListener[]{EJB3AutoFlushEventListener.INSTANCE} );
- listenerConfig.setDeleteEventListeners( new DeleteEventListener[]{new EJB3DeleteEventListener()} );
+ listenerConfig.setAutoFlushEventListeners( new AutoFlushEventListener[] { EJB3AutoFlushEventListener.INSTANCE } );
+ listenerConfig.setDeleteEventListeners( new DeleteEventListener[] { new EJB3DeleteEventListener() } );
listenerConfig.setFlushEntityEventListeners(
- new FlushEntityEventListener[]{new EJB3FlushEntityEventListener()}
+ new FlushEntityEventListener[] { new EJB3FlushEntityEventListener() }
);
- listenerConfig.setMergeEventListeners( new MergeEventListener[]{new EJB3MergeEventListener()} );
- listenerConfig.setPersistEventListeners( new PersistEventListener[]{new EJB3PersistEventListener()} );
+ listenerConfig.setMergeEventListeners( new MergeEventListener[] { new EJB3MergeEventListener() } );
+ listenerConfig.setPersistEventListeners( new PersistEventListener[] { new EJB3PersistEventListener() } );
listenerConfig.setPersistOnFlushEventListeners(
- new PersistEventListener[]{new EJB3PersistOnFlushEventListener()}
+ new PersistEventListener[] { new EJB3PersistOnFlushEventListener() }
);
- listenerConfig.setSaveEventListeners( new SaveOrUpdateEventListener[]{new EJB3SaveEventListener()} );
+ listenerConfig.setSaveEventListeners( new SaveOrUpdateEventListener[] { new EJB3SaveEventListener() } );
listenerConfig.setSaveOrUpdateEventListeners(
- new SaveOrUpdateEventListener[]{new EJB3SaveOrUpdateEventListener()}
+ new SaveOrUpdateEventListener[] { new EJB3SaveOrUpdateEventListener() }
);
//Pre events
listenerConfig.setPreInsertEventListeners(
- new PreInsertEventListener[]{
+ new PreInsertEventListener[] {
new JACCPreInsertEventListener(),
}
);
listenerConfig.setPreUpdateEventListeners(
- new PreUpdateEventListener[]{
+ new PreUpdateEventListener[] {
new JACCPreUpdateEventListener(),
}
);
listenerConfig.setPreDeleteEventListeners(
- new PreDeleteEventListener[]{
+ new PreDeleteEventListener[] {
new JACCPreDeleteEventListener()
}
);
listenerConfig.setPreLoadEventListeners(
- new PreLoadEventListener[]{
+ new PreLoadEventListener[] {
new JACCPreLoadEventListener()
}
);
//post events
listenerConfig.setPostDeleteEventListeners(
- new PostDeleteEventListener[]{new EJB3PostDeleteEventListener()}
+ new PostDeleteEventListener[] { new EJB3PostDeleteEventListener() }
);
listenerConfig.setPostInsertEventListeners(
- new PostInsertEventListener[]{new EJB3PostInsertEventListener()}
+ new PostInsertEventListener[] { new EJB3PostInsertEventListener() }
);
listenerConfig.setPostLoadEventListeners(
- new PostLoadEventListener[]{new EJB3PostLoadEventListener()}
+ new PostLoadEventListener[] { new EJB3PostLoadEventListener() }
);
listenerConfig.setPostUpdateEventListeners(
- new PostUpdateEventListener[]{new EJB3PostUpdateEventListener()}
+ new PostUpdateEventListener[] { new EJB3PostUpdateEventListener() }
);
}
@@ -138,7 +137,7 @@
while ( st.hasMoreElements() ) {
listeners.add( (String) st.nextElement() );
}
- configuration.setListeners( type, listeners.toArray( new String[ listeners.size() ] ) );
+ configuration.setListeners( type, listeners.toArray( new String[listeners.size()] ) );
}
}
}
@@ -158,7 +157,7 @@
callbackHandler.add( reflectionManager.classForName( clazz.getClassName(), this.getClass() ), reflectionManager );
}
catch (ClassNotFoundException e) {
- throw new MappingException("entity class not found: " + clazz.getNodeName(), e);
+ throw new MappingException( "entity class not found: " + clazz.getNodeName(), e );
}
}
}
@@ -170,7 +169,7 @@
beanInfo = Introspector.getBeanInfo( listenerConfig.getClass(), Object.class );
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
try {
- for ( int i = 0, max = pds.length; i < max ; i++ ) {
+ for (int i = 0, max = pds.length; i < max; i++) {
final Object listeners = pds[i].getReadMethod().invoke( listenerConfig, READER_METHOD_ARGS );
if ( listeners == null ) {
throw new HibernateException( "Listener [" + pds[i].getName() + "] was null" );
@@ -178,7 +177,7 @@
if ( listeners instanceof Object[] ) {
int securityListenersNbr = 0;
Object[] listenersArray = (Object[]) listeners;
- for ( Object listener : listenersArray ) {
+ for (Object listener : listenersArray) {
if ( listener != null && listener instanceof CallbackHandlerConsumer ) {
( (CallbackHandlerConsumer) listener ).setCallbackHandler( callbackHandler );
}
@@ -192,8 +191,8 @@
Class clazz = pds[i].getReadMethod().getReturnType().getComponentType();
Object newArray = Array.newInstance( clazz, listenersArray.length - securityListenersNbr );
int index = 0;
- for ( Object listener : listenersArray ) {
- if ( ! ( listener != null && listener instanceof JACCSecurityListener ) ) {
+ for (Object listener : listenersArray) {
+ if ( !( listener != null && listener instanceof JACCSecurityListener ) ) {
Array.set( newArray, index++, listener );
}
}
Modified: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/Cat.java 2007-08-11 06:47:32 UTC (rev 12922)
@@ -20,14 +20,11 @@
import javax.persistence.TemporalType;
import javax.persistence.Transient;
-import org.hibernate.validator.Length;
-import org.hibernate.validator.Min;
-
/**
* @author Emmanuel Bernard
*/
@Entity
-(a)EntityListeners(LastUpdateListener.class)
+@EntityListeners( LastUpdateListener.class )
public class Cat implements Serializable {
private Integer id;
private String name;
@@ -49,7 +46,6 @@
this.id = id;
}
- @Length(min = 4)
public String getName() {
return name;
}
@@ -84,7 +80,7 @@
}
@Basic
- @Temporal(TemporalType.TIMESTAMP)
+ @Temporal( TemporalType.TIMESTAMP )
public Date getLastUpdate() {
return lastUpdate;
}
@@ -128,7 +124,6 @@
return Collections.unmodifiableList( ids );
}
- @Min(0)
public long getLength() {
return length;
}
Modified: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/PackagedEntityManagerTest.java 2007-08-11 06:47:32 UTC (rev 12922)
@@ -22,13 +22,11 @@
import org.hibernate.ejb.test.pack.explodedpar.Elephant;
import org.hibernate.ejb.test.pack.externaljar.Scooter;
import org.hibernate.ejb.test.pack.spacepar.Bug;
-import org.hibernate.ejb.test.pack.various.Seat;
import org.hibernate.ejb.test.pack.various.Airplane;
-import org.hibernate.stat.Statistics;
-import org.hibernate.validator.InvalidStateException;
-import org.hibernate.JDBCException;
-import org.hibernate.event.EventListeners;
+import org.hibernate.ejb.test.pack.various.Seat;
import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.EventListeners;
+import org.hibernate.stat.Statistics;
//$Id$
@@ -38,7 +36,7 @@
public class PackagedEntityManagerTest extends TestCase {
public Class[] getAnnotatedClasses() {
- return new Class[]{
+ return new Class[] {
};
}
@@ -141,7 +139,7 @@
if ( nested == null ) throw e;
nested = nested.getCause();
if ( nested == null ) throw e;
- if ( ! ( nested instanceof ClassNotFoundException ) ) throw e;
+ if ( !( nested instanceof ClassNotFoundException ) ) throw e;
fail( "Try to process hbm file: " + e.getMessage() );
}
EntityManager em = emf.createEntityManager();
@@ -184,7 +182,7 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "space par", new HashMap() );
EntityManager em = emf.createEntityManager();
Bug bug = new Bug();
- bug.setSubject( "Spaces in directory name don't play well on Windows");
+ bug.setSubject( "Spaces in directory name don't play well on Windows" );
em.getTransaction().begin();
em.persist( bug );
em.flush();
@@ -205,7 +203,7 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "overridenpar", properties );
EntityManager em = emf.createEntityManager();
org.hibernate.ejb.test.pack.overridenpar.Bug bug = new org.hibernate.ejb.test.pack.overridenpar.Bug();
- bug.setSubject( "Allow DS overriding");
+ bug.setSubject( "Allow DS overriding" );
em.getTransaction().begin();
em.persist( bug );
em.flush();
@@ -221,10 +219,10 @@
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
EntityManager em = emf.createEntityManager();
EventListeners eventListeners = ( (SessionImplementor) em.getDelegate() ).getListeners();
- assertEquals(
+ assertEquals(
"Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
eventListeners.getPreInsertEventListeners().length,
- eventListeners.getPreUpdateEventListeners().length + 1);
+ eventListeners.getPreUpdateEventListeners().length + 1 );
em.close();
emf.close();
@@ -388,7 +386,7 @@
second = em.find( Item.class, item.getName() );
assertEquals( 1, second.getDistributors().size() );
assertEquals( 3, stats.getSecondLevelCacheHitCount() );
- for ( Distributor distro : second.getDistributors() ) {
+ for (Distributor distro : second.getDistributors()) {
em.remove( distro );
}
em.remove( second );
@@ -422,7 +420,7 @@
Seat seat = new Seat();
seat.setNumber( "3B" );
Airplane plane = new Airplane();
- plane.setSerialNumber( "75924418409052355");
+ plane.setSerialNumber( "75924418409052355" );
em.getTransaction().begin();
em.persist( seat );
em.persist( plane );
Deleted: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ValidatorIntegrationTest.java 2007-08-11 06:47:32 UTC (rev 12922)
@@ -1,41 +0,0 @@
-//$Id$
-package org.hibernate.ejb.test;
-
-import java.util.Date;
-import javax.persistence.EntityManager;
-
-import org.hibernate.validator.InvalidStateException;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ValidatorIntegrationTest extends TestCase {
-
- public void testPropertyValidation() throws Exception {
- EntityManager em = factory.createEntityManager();
- Cat cat = new Cat();
- cat.setAge( 33 );
- cat.setDateOfBirth( new Date() );
- cat.setName( "iti" );
- em.getTransaction().begin();
- try {
- em.persist( cat );
- em.flush();
- fail( "No validation" );
- }
- catch (InvalidStateException e) {
- //success
- }
- finally {
- em.getTransaction().rollback();
- em.close();
- }
-
- }
-
- public Class[] getAnnotatedClasses() {
- return new Class[]{
- Cat.class
- };
- }
-}
Deleted: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java 2007-08-11 06:47:02 UTC (rev 12921)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/EventOverridingTest.java 2007-08-11 06:47:32 UTC (rev 12922)
@@ -1,50 +0,0 @@
-//$Id$
-package org.hibernate.ejb.test.ejb3configuration;
-
-import java.util.HashMap;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-
-import org.hibernate.ejb.test.Cat;
-import org.hibernate.ejb.HibernateEntityManagerFactory;
-import org.hibernate.event.EventListeners;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-
-/**
- * @author Emmanuel Bernard
- */
-public class EventOverridingTest extends TestCase {
-
- public void testEventOverriding() throws Exception {
- EventListeners eventListeners = configuration.getEventListeners();
- assertEquals( 1, eventListeners.getPreInsertEventListeners().length );
- eventListeners.setPreInsertEventListeners( new PreInsertEventListener[]{} );
- Cat cat = new Cat();
- cat.setLength( 3 );
- cat.setAge( 34 );
- cat.setName( "Did" ); //should raise a validation exception
- EntityManagerFactory entityManagerFactory = configuration.createEntityManagerFactory();
- EntityManager em = entityManagerFactory.createEntityManager();
- assertEquals( "only validator should be present", 1,
- ( (SessionImplementor) em.getDelegate() ).getListeners().getPreInsertEventListeners().length);
- em.close();
- }
-
- public void testEventPerProperties() throws Exception {
- EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
- EntityManager em = emf.createEntityManager();
- assertEquals( "Only validator and explicit NoOp should be present", 2,
- ( (SessionImplementor) em.getDelegate() ).getListeners().getPreInsertEventListeners().length);
- em.close();
- emf.close();
- }
-
- public Class[] getAnnotatedClasses() {
- return new Class[]{
- Cat.class
- };
- }
-}
17 years, 4 months
Hibernate SVN: r12921 - trunk/HibernateExt/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-11 02:47:02 -0400 (Sat, 11 Aug 2007)
New Revision: 12921
Modified:
trunk/HibernateExt/annotations/build.properties.dist
trunk/HibernateExt/annotations/build.xml
Log:
Remove dependency in tests from ann -> validator
Modified: trunk/HibernateExt/annotations/build.properties.dist
===================================================================
--- trunk/HibernateExt/annotations/build.properties.dist 2007-08-11 06:02:44 UTC (rev 12920)
+++ trunk/HibernateExt/annotations/build.properties.dist 2007-08-11 06:47:02 UTC (rev 12921)
@@ -5,5 +5,4 @@
#locally present jars
jpa-api.jar=./lib/ejb3-persistence.jar
-commons-annotations.jar=./lib/hibernate-commons-annotations.jar
-validator.jar=./lib/test/hibernate-validator.jar
\ No newline at end of file
+commons-annotations.jar=./lib/hibernate-commons-annotations.jar
\ No newline at end of file
Modified: trunk/HibernateExt/annotations/build.xml
===================================================================
--- trunk/HibernateExt/annotations/build.xml 2007-08-11 06:02:44 UTC (rev 12920)
+++ trunk/HibernateExt/annotations/build.xml 2007-08-11 06:47:02 UTC (rev 12921)
@@ -219,9 +219,6 @@
<fileset file="${commons-annotations.jar}"/>
</copy>
<mkdir dir="${dist.lib.dir}/test"/>
- <copy todir="${dist.lib.dir}/test" failonerror="false">
- <fileset file="${validator.jar}"/>
- </copy>
<copy file="${basedir}/build.properties.dist" tofile="${dist.dir}/build.properties" failonerror="false">
</copy>
17 years, 4 months
Hibernate SVN: r12920 - in trunk/HibernateExt/annotations: src/test/org/hibernate/test/annotations/tableperclass and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-11 02:02:44 -0400 (Sat, 11 Aug 2007)
New Revision: 12920
Modified:
trunk/HibernateExt/annotations/build.xml
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/tableperclass/Component.java
Log:
Remove dependency in tests from ann -> validator
Modified: trunk/HibernateExt/annotations/build.xml
===================================================================
--- trunk/HibernateExt/annotations/build.xml 2007-08-10 19:46:42 UTC (rev 12919)
+++ trunk/HibernateExt/annotations/build.xml 2007-08-11 06:02:44 UTC (rev 12920)
@@ -25,8 +25,6 @@
<property name="common.dir" value="../common"/>
<property name="jpa-api.jar" value="${basedir}/../jpa-api/build/ejb3-persistence.jar"/>
- <property name="validator.jar"
- value="${basedir}/../validator/target/hibernate-validator/hibernate-validator.jar"/>
<property name="commons-annotations.jar"
value="${basedir}/../commons-annotations/target/hibernate-commons-annotations/hibernate-commons-annotations.jar"/>
@@ -43,7 +41,6 @@
<path id="junit.moduleclasspath">
<pathelement location="${src.dir}"/>
<pathelement location="${test.dir}"/>
- <pathelement location="${validator.jar}"/>
<pathelement location="lib/testlibs/org.eclipse.jdt.core_3.1.0.jar"/>
<fileset dir="${jdbc.dir}">
<include name="**/*.jar"/>
@@ -55,7 +52,6 @@
<antcall target="common-build.init"/>
<available file="${jpa-api.jar}" type="file" property="jpa-api.jar.available"/>
<available file="${commons-annotations.jar}" type="file" property="commons-annotations.jar.available"/>
- <available file="${validator.jar}" type="file" property="validator.jar.available"/>
<mkdir dir="${lib.dir}/test"/>
</target>
@@ -69,11 +65,6 @@
<ant inheritall="false" dir="${basedir}/../commons-annotations" target="jar"/>
</target>
- <target name="get.validator" depends="init" unless="validator.jar.available">
- <ant inheritall="false" dir="${basedir}/../validator" target="clean"/>
- <ant inheritall="false" dir="${basedir}/../validator" target="jar"/>
- </target>
-
<target name="compile" depends="init,get.jpa-api,get.commons-annotations"
description="Compile the Java source code">
<available
@@ -100,7 +91,7 @@
</copy>
</target>
- <target name="compiletest" depends="compile,get.validator" description="Compile the tests">
+ <target name="compiletest" depends="compile" description="Compile the tests">
<available
classname="org.eclipse.core.launcher.Main"
property="build.compiler"
Modified: trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/tableperclass/Component.java
===================================================================
--- trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/tableperclass/Component.java 2007-08-10 19:46:42 UTC (rev 12919)
+++ trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/tableperclass/Component.java 2007-08-11 06:02:44 UTC (rev 12920)
@@ -1,13 +1,12 @@
//$Id: $
package org.hibernate.test.annotations.tableperclass;
+import javax.persistence.Column;
+import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
-import javax.persistence.Entity;
import javax.persistence.InheritanceType;
-import org.hibernate.validator.NotNull;
-import org.hibernate.validator.Length;
import org.hibernate.annotations.Index;
/**
@@ -32,15 +31,13 @@
return id;
}
-
- @NotNull
- @Length(max = 40)
+ @Column(nullable = false)
@Index(name = "manufacturerPartNumber")
public String getManufacturerPartNumber() {
return manufacturerPartNumber;
}
- @NotNull
+ @Column(nullable = false)
public Long getManufacturerId() {
return manufacturerId;
}
17 years, 4 months
Hibernate SVN: r12919 - tags/entitymanager_v3_3_1_GA.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-10 15:46:42 -0400 (Fri, 10 Aug 2007)
New Revision: 12919
Added:
tags/entitymanager_v3_3_1_GA/HibernateExt/
Log:
release HEM 3.3.1.GA: forgot to tag
Copied: tags/entitymanager_v3_3_1_GA/HibernateExt (from rev 11358, trunk/HibernateExt)
17 years, 4 months
Hibernate SVN: r12918 - tags.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-08-10 15:45:23 -0400 (Fri, 10 Aug 2007)
New Revision: 12918
Added:
tags/entitymanager_v3_3_1_GA/
Log:
release HEM 3.3.1.GA: forgot to tag
17 years, 4 months