Synced with H2 doco

git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@4215 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Christian Bauer 2004-08-10 03:08:00 +00:00
parent c44204af8a
commit bc18e67174
10 changed files with 207 additions and 80 deletions

View File

@ -54,7 +54,8 @@
<antcall target="lang.htmlmisc"/>
</target>
<target name="lang.docpdf">
<target name="lang.docpdf.prepare">
<!-- Copy all the images to the output location, will be removed later. -->
<copy todir="${build.dir}/${lang}/pdf/images">
@ -74,17 +75,42 @@
<arg value="${basedir}/${lang}/styles/${db.style.fopdf}"/>
</java>
<available property="custom.fop.userconfig.present" file="userconfig.xml" filepath="${basedir}/${lang}/fop"/>
</target>
<target name="lang.docpdf.customized" depends="lang.docpdf.prepare" if="custom.fop.userconfig.present">
<copy todir="${build.dir}/${lang}/pdf">
<fileset dir="${basedir}/${lang}/fop">
<include name="*"/>
</fileset>
</copy>
<!-- Create a PDF from the XSL/FO, using customized fop userconfig.xml -->
<java classname="org.apache.fop.apps.Fop" fork="true" dir="${basedir}">
<classpath refid="lib.classpath"/>
<arg value="-c"/>
<arg value="${basedir}/${lang}/fop/userconfig.xml"/>
<arg value="${build.dir}/${lang}/pdf/docbook_fop.tmp"/>
<arg value="${build.dir}/${lang}/pdf/hibernate_reference.pdf"/>
</java>
</target>
<target name="lang.docpdf.normal" depends="lang.docpdf.prepare" unless="custom.fop.userconfig.present">
<!-- Create a PDF from the XSL/FO. -->
<java classname="org.apache.fop.apps.Fop" fork="true" dir="${basedir}">
<classpath refid="lib.classpath"/>
<arg value="${build.dir}/${lang}/pdf/docbook_fop.tmp"/>
<arg value="${build.dir}/${lang}/pdf/hibernate_reference.pdf"/>
</java>
</target>
<!-- Delete temporary files. -->
<delete file="${build.dir}/${lang}/pdf/docbook_fop.tmp"/>
<target name="lang.docpdf" depends="lang.docpdf.normal,lang.docpdf.customized">
<!-- House keeping,delete temporary files. -->
<delete>
<fileset dir="${build.dir}/${lang}/pdf" excludes="**/*.pdf"/>
</delete>
<delete dir="${build.dir}/${lang}/pdf/images"/>
</target>
<target name="lang.dochtml">

View File

@ -28,12 +28,12 @@
<bookinfo>
<title>HIBERNATE - Relational Persistence for Idiomatic Java</title>
<subtitle>Hibernate Reference Documentation</subtitle>
<releaseinfo>3.0</releaseinfo>
<releaseinfo>3.0alpha</releaseinfo>
</bookinfo>
<toc/>
<preface id="preface">
<preface id="preface" revision="1">
<title>Preface</title>
<para>
@ -83,7 +83,7 @@
Have a look at the <literal>eg/</literal> directory in the Hibernate
distribution, it contains a simple standalone application. Copy your
JDBC driver to the <literal>lib/</literal> directory and edit
<literal>src/hibernate.properties</literal>, specifying correct values for
<literal>etc/hibernate.properties</literal>, specifying correct values for
your database. From a command prompt in the distribution directory,
type <literal>ant eg</literal> (using Ant), or under Windows, type
<literal>build eg</literal>.
@ -92,19 +92,24 @@
<listitem>
<para>
Use this reference documentation as your primary source of information.
Consider reading <emphasis>Hibernate in Action</emphasis>
(http://www.manning.com/bauer) if you need more help with application
design or if you prefer a step-by-step tutorial. Also visit
http://caveatemptor.hibernate.org and download the example application
for Hibernate in Action.
</para>
</listitem>
<listitem>
<para>
FAQs are answered on the Hibernate website.
</para>
</listitem>
<listitem>
<para>
Third party demos, examples and tutorials are linked on the Hibernate
website.
</para>
<para>
FAQs are answered on the Hibernate website.
</para>
</listitem>
<listitem>
<para>
Third party demos, examples and tutorials are linked on the Hibernate
website.
</para>
</listitem>
<listitem>
<para>
The Community Area on the Hibernate website is a good source for
@ -115,7 +120,7 @@
<listitem>
<para>
An offline version of the Hibernate website is distributed with
Hibernate in the <literal>doc/</literal> subdirectory.
Hibernate in the <literal>doc/wiki/</literal> subdirectory.
</para>
</listitem>
</orderedlist>
@ -123,13 +128,15 @@
<para>
If you have questions, use the user forum linked on the Hibernate website. We also
provide a JIRA issue trackings system for bug reports and feature requests. If you
are interested in the development of Hibernate, join the developer mailing list.
are interested in the development of Hibernate, join the developer mailing list. If
you are interested in translating this documentation into your language, contact us
on the developer mailing list.
</para>
<para>
Commercial development, production support and training for Hibernate is available
through JBoss Inc. (see http://www.hibernate.org/SupportTraining/). Hibernate is a
project of the JBoss Professional Open Source product suite.
Commercial development support, production support and training for Hibernate is
available through JBoss Inc. (see http://www.hibernate.org/SupportTraining/).
Hibernate is a project of the JBoss Professional Open Source product suite.
</para>
</preface>

View File

@ -739,7 +739,7 @@
</sect2>
<sect2 id="mapping-declaration-discriminator">
<sect2 id="mapping-declaration-discriminator" revision="1">
<title>discriminator</title>
<para>
@ -757,11 +757,13 @@
<area id="discriminator1" coords="2 40"/>
<area id="discriminator2" coords="3 40" />
<area id="discriminator3" coords="4 40" />
<area id="discriminator4" coords="5 40" />
</areaspec>
<programlisting><![CDATA[<discriminator
column="discriminator_column"
type="discriminator_type"
force="true|false"
insert="true|false"
/>]]></programlisting>
<calloutlist>
<callout arearefs="discriminator1">
@ -783,6 +785,13 @@
all instances of the root class.
</para>
</callout>
<callout arearefs="discriminator4">
<para>
<literal>insert</literal> (optional - defaults to <literal>true</literal>)
set this to <literal>false</literal> if your discriminator column is also part
of a mapped composite identifier.
</para>
</callout>
</calloutlist>
</programlistingco>
@ -1055,7 +1064,7 @@
</sect2>
<sect2 id="mapping-declaration-manytoone">
<sect2 id="mapping-declaration-manytoone" revision="1">
<title>many-to-one</title>
<para>
@ -1077,6 +1086,7 @@
</areaset>
<area id="manytoone8" coords="9 60"/>
<area id="manytoone9" coords="10 60"/>
<area id="manytoone10" coords="11 60"/>
</areaspec>
<programlisting><![CDATA[<many-to-one
name="propertyName"
@ -1088,6 +1098,7 @@
insert="true|false"
property-ref="propertyNameFromAssociatedClass"
access="field|property|ClassName"
unique="true|false"
/>]]></programlisting>
<calloutlist>
<callout arearefs="manytoone1">
@ -1141,6 +1152,12 @@
strategy Hibernate should use for accessing the property value.
</para>
</callout>
<callout arearefs="manytoone10">
<para>
<literal>unique</literal> (optional): Enable the DDL generation of a unique
constraint for the foreign-key column.
</para>
</callout>
</calloutlist>
</programlistingco>

View File

@ -1,5 +1,4 @@
<chapter id="best-practices">
<chapter id="best-practices" revision="2">
<title>Best Practices</title>
<variablelist spacing="compact">
@ -121,8 +120,13 @@
<term>In a two tiered architecture, consider using session disconnection.</term>
<listitem>
<para>
When using a servlet only, you may reuse the same session for multiple client requests. Just
remember to disconnect the session before returning control to the client.
Database Transactions have to be as short as possible for best scalability. However, it is often
neccessary to implement long running Application Transactions, a single unit-of-work from the
point of view of a user. This Application Transaction might span several client requests and
response cycles. Either use Detached Objects or, in two tiered architectures, simply disconnect
the Hibernate Session from the JDBC connection and reconnect it for each subsequent request. Never
use a single Session for more than one Application Transaction usecase, otherwise, you will run
into stale data.
</para>
</listitem>
</varlistentry>
@ -134,7 +138,8 @@
the <literal>Transaction</literal> and close the <literal>Session</literal>. If you don't, Hibernate
can't guarantee that in-memory state accurately represents persistent state. As a special case of this,
do not use <literal>Session.load()</literal> to determine if an instance with the given identifier
exists on the database; use <literal>find()</literal> instead.
exists on the database; use <literal>find()</literal> instead. Some exceptions are recoverable, for
example the <literal>StaleObjectStateException</literal> and <literal>ObjectNotFoundException</literal>.
</para>
</listitem>
</varlistentry>
@ -162,6 +167,35 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Implement <literal>equals()</literal> and <literal>hashCode()</literal> using a unique business key.</term>
<listitem>
<para>
If you compare objects outside of the Session scope, you have to implement <literal>equals()</literal>
and <literal>hashCode()</literal>. Inside the Session scope, Java object identity is guaranteed. If
you implement these methods, never ever use the database identifier! A transient object doesn't have
an identifier value and Hibernate would assign a value when the object is saved. If the object
is in a Set while being saved, the hash code changes, breaking the contract. To implement
<literal>equals()</literal> and <literal>hashCode()</literal>, use a unique business key, that is,
compare a unique combination of class properties. Remember that this key has to be stable and unique
only while the object is in a Set, not for the whole lifetime (not as stable as a database primary
key). Never use collections in the <literal>equals()</literal> comparison (lazy loading) and be careful
with other associated classes that might be proxied.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Don't use exotic association mappings.</term>
<listitem>
<para>
Good usecases for a real many-to-many associations are rare. Most of the time you need
additional information stored in the "link table". In this case, it is much better to
use two one-to-many associations to an intermediate link class. In fact, we think that
most associations are one-to-many and many-to-one, you should be careful when using any
other association style and ask yourself if it is really neccessary.
</para>
</listitem>
</varlistentry>
</variablelist>
</chapter>

View File

@ -359,7 +359,7 @@ hibernate.dialect = \
<literal>Properties</literal> passed to the <literal>Configuration</literal>.
</para>
<table frame="topbot" id="configuration-optional-properties" revision="1">
<table frame="topbot" id="configuration-optional-properties" revision="3">
<title>Hibernate Configuration Properties</title>
<tgroup cols="2">
<colspec colname="c1" colwidth="1*"/>
@ -452,11 +452,26 @@ hibernate.dialect = \
<entry>
A non-zero value enables use of JDBC2 batch updates by Hibernate.
<para>
<emphasis role="strong">eg.</emphasis>
<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.use_scrollable_resultset</literal>
@ -507,8 +522,9 @@ hibernate.dialect = \
</entry>
<entry>
Enables use of CGLIB instead of runtime reflection (System-level
property, default is to use CGLIB where possible). Reflection
can sometimes be useful when troubleshooting.
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>
@ -596,6 +612,19 @@ hibernate.dialect = \
</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>
@ -707,7 +736,7 @@ hibernate.dialect = \
other properties listed above, saving you the effort of specifying them manually.
</para>
<table frame="topbot">
<table frame="topbot" id="sql-dialects" revision="2">
<title>Hibernate SQL Dialects (<literal>hibernate.dialect</literal>)</title>
<tgroup cols="2">
<colspec colwidth="1*"/>
@ -723,16 +752,22 @@ hibernate.dialect = \
<entry>DB2</entry> <entry><literal>net.sf.hibernate.dialect.DB2Dialect</literal></entry>
</row>
<row>
<entry>MySQL</entry> <entry><literal>net.sf.hibernate.dialect.MySQLDialect</literal></entry>
<entry>DB2 AS/400</entry> <entry><literal>net.sf.hibernate.dialect.DB2400Dialect</literal></entry>
</row>
<row>
<entry>SAP DB</entry> <entry><literal>net.sf.hibernate.dialect.SAPDBDialect</literal></entry>
<entry>DB2 OS390</entry> <entry><literal>net.sf.hibernate.dialect.DB2390Dialect</literal></entry>
</row>
<row>
<entry>PostgreSQL</entry> <entry><literal>net.sf.hibernate.dialect.PostgreSQLDialect</literal></entry>
</row>
<row>
<entry>MySQL</entry> <entry><literal>net.sf.hibernate.dialect.MySQLDialect</literal></entry>
</row>
<row>
<entry>Oracle (any version)</entry> <entry><literal>net.sf.hibernate.dialect.OracleDialect</literal></entry>
</row>
<row>
<entry>Oracle 9</entry> <entry><literal>net.sf.hibernate.dialect.Oracle9Dialect</literal></entry>
<entry>Oracle 9/10g</entry> <entry><literal>net.sf.hibernate.dialect.Oracle9Dialect</literal></entry>
</row>
<row>
<entry>Sybase</entry> <entry><literal>net.sf.hibernate.dialect.SybaseDialect</literal></entry>
@ -740,6 +775,21 @@ hibernate.dialect = \
<row>
<entry>Sybase Anywhere</entry> <entry><literal>net.sf.hibernate.dialect.SybaseAnywhereDialect</literal></entry>
</row>
<row>
<entry>Microsoft SQL Server</entry> <entry><literal>net.sf.hibernate.dialect.SQLServerDialect</literal></entry>
</row>
<row>
<entry>SAP DB</entry> <entry><literal>net.sf.hibernate.dialect.SAPDBDialect</literal></entry>
</row>
<row>
<entry>Informix</entry> <entry><literal>net.sf.hibernate.dialect.InformixDialect</literal></entry>
</row>
<row>
<entry>HypersonicSQL</entry> <entry><literal>net.sf.hibernate.dialect.HSQLDialect</literal></entry>
</row>
<row>
<entry>Ingres</entry> <entry><literal>net.sf.hibernate.dialect.IngresDialect</literal></entry>
</row>
<row>
<entry>Progress</entry> <entry><literal>net.sf.hibernate.dialect.ProgressDialect</literal></entry>
</row>
@ -752,24 +802,12 @@ hibernate.dialect = \
<row>
<entry>Pointbase</entry> <entry><literal>net.sf.hibernate.dialect.PointbaseDialect</literal></entry>
</row>
<row>
<entry>PostgreSQL</entry> <entry><literal>net.sf.hibernate.dialect.PostgreSQLDialect</literal></entry>
</row>
<row>
<entry>HypersonicSQL</entry> <entry><literal>net.sf.hibernate.dialect.HSQLDialect</literal></entry>
</row>
<row>
<entry>Microsoft SQL Server</entry> <entry><literal>net.sf.hibernate.dialect.SQLServerDialect</literal></entry>
</row>
<row>
<entry>Ingres</entry> <entry><literal>net.sf.hibernate.dialect.IngresDialect</literal></entry>
</row>
<row>
<entry>Informix</entry> <entry><literal>net.sf.hibernate.dialect.InformixDialect</literal></entry>
</row>
<row>
<entry>FrontBase</entry> <entry><literal>net.sf.hibernate.dialect.FrontbaseDialect</literal></entry>
</row>
<row>
<entry>Firebird</entry> <entry><literal>net.sf.hibernate.dialect.FirebirdDialect</literal></entry>
</row>
</tbody>
</tgroup>
</table>
@ -892,39 +930,39 @@ hibernate.dialect = \
</thead>
<tbody>
<row>
<entry><literal>org.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.JBossTransactionManagerLookup</literal></entry>
<entry align="center">JBoss</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</literal></entry>
<entry align="center">Weblogic</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.WebSphereTransactionManagerLookup</literal></entry>
<entry align="center">WebSphere</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.OrionTransactionManagerLookup</literal></entry>
<entry align="center">Orion</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.ResinTransactionManagerLookup</literal></entry>
<entry align="center">Resin</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.JOTMTransactionManagerLookup</literal></entry>
<entry align="center">JOTM</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.JOnASTransactionManagerLookup</literal></entry>
<entry align="center">JOnAS</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.JRun4TransactionManagerLookup</literal></entry>
<entry align="center">JRun4</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
<entry><literal>net.sf.hibernate.transaction.BESTransactionManagerLookup</literal></entry>
<entry align="center">Borland ES</entry>
</row>
</tbody>

View File

@ -348,7 +348,7 @@ List cats = q.list();]]></programlisting>
</sect2>
<sect2 id="manipulatingdata-scrolling">
<sect2 id="manipulatingdata-scrolling" revision="1">
<title>Scrollable iteration</title>
<para>
If your JDBC driver supports scrollable <literal>ResultSet</literal>s, the <literal>Query</literal>
@ -376,12 +376,6 @@ if ( cats.first() ) {
while( ( PAGE_SIZE > i++ ) && cats.next() ) pageOfCats.add( cats.get(1) );
}]]></programlisting>
<para>
The behaviour of <literal>scroll()</literal> is similar to <literal>iterate()</literal>, except that
objects may be initialized selectively by <literal>get(int)</literal>, instead of an entire row being
initialized at once.
</para>
</sect2>

View File

@ -643,7 +643,7 @@ while ( cats.hasNext() ) {
</sect1>
<sect1 id="performance-querycache">
<sect1 id="performance-querycache" revision="1">
<title>The Query Cache</title>
<para>
@ -679,6 +679,17 @@ while ( cats.hasNext() ) {
.setCacheRegion("frontpages")
.list();]]></programlisting>
<para>
If the query should force a refresh of its query cache region, you may call
<literal>Query.setForceCacheRefresh()</literal> to <literal>true</literal>.
This is particularly useful in cases where underlying data may have been updated
via a seperate process (i.e., not modified through Hibernate) and allows the
application to selectively refresh the query cache regions based on its
knowledge of those events. This is an alternative to eviction of a query
cache region. If you need fine-grained refresh control for many queries, use
this function instead of a new region for each query.
</para>
</sect1>
</chapter>

View File

@ -41,14 +41,14 @@
</para>
</listitem>
<listitem>
<para>
Never copy anything else into the global classloader path in Tomcat, or you
will get problems with various tools, including Log4j, commons-logging and
others. Always use the context classpath for each web application, that is,
copy libraries to <literal>WEB-INF/lib</literal> and your own classes and
configuration/property files to <literal>WEB-INF/classes</literal>. Both
directories are in the context level classpath by default.
</para>
<para>
Never copy anything else into the global classloader path in Tomcat, or you
will get problems with various tools, including Log4j, commons-logging and
others. Always use the context classpath for each web application, that is,
copy libraries to <literal>WEB-INF/lib</literal> and your own classes and
configuration/property files to <literal>WEB-INF/classes</literal>. Both
directories are in the context level classpath by default.
</para>
</listitem>
<listitem>
<para>
@ -163,7 +163,7 @@
Hibernate. This means Tomcat will provide pooled JDBC connections (using its
builtin DBCP pooling feature), Hibernate requests theses connections through
JNDI. Tomcat binds the connection pool to JNDI, we add a resource declaration
to Tomcat's main configuration file, <literal>TOMCAT/conf/server.xml</literal>:
to Tomcats main configuration file, <literal>TOMCAT/conf/server.xml</literal>:
</para>
<programlisting><![CDATA[<Context path="/quickstart" docBase="quickstart">
@ -470,10 +470,10 @@ Indexes: cat_pkey primary key btree (cat_id)]]></programlisting>
A <literal>SessionFactory</literal> is usually only build once,
e.g. at startup with a <emphasis>load-on-startup</emphasis> servlet.
This also means you should not keep it in an instance variable in your
servlets, but in some other location. We need some kind of
servlets, but in some other location. Furthermore, we need some kind of
<emphasis>Singleton</emphasis>, so we can access the
<literal>SessionFactory</literal> easily. The approach shown next
solves both problems: configuration and easy access to a
<literal>SessionFactory</literal> easily in application code. The approach
shown next solves both problems: configuration and easy access to a
<literal>SessionFactory</literal>.
</para>

Binary file not shown.

Binary file not shown.