From: <one...@us...> - 2002-11-21 09:04:03
|
Update of /cvsroot/hibernate/Hibernate/doc/reference/html_single In directory sc8-pr-cvs1:/tmp/cvs-serv679/doc/reference/html_single Modified Files: index.html Log Message: calendar types Index: index.html =================================================================== RCS file: /cvsroot/hibernate/Hibernate/doc/reference/html_single/index.html,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** index.html 19 Nov 2002 15:35:35 -0000 1.81 --- index.html 21 Nov 2002 09:03:27 -0000 1.82 *************** *** 1,5 **** <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr noshade="true"></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt>2.1. <a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt>2.2. <a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt>2.3. <a href="#session-configuration-s3">User provided JDBC Connection</a></dt><dt>2.4. <a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt>2.5. <a href="#session-configuration-s5">Other properties</a></dt><dt>2.6. <a href="#session-configuration-s6">XML Configuration File</a></dt><dt>2.7. <a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt>3.1. <a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt>3.1.1. <a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt>3.1.2. <a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt>3.1.3. <a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt>3.2. <a href="#persistent-classes-s2">Inheritance</a></dt><dt>3.3. <a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt>3.4. <a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt>4.1. <a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt>4.1.1. <a href="#or-mapping-s1-1">Doctype</a></dt><dt>4.1.2. <a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt>4.1.3. <a href="#or-mapping-s1-3">class</a></dt><dt>4.1.4. <a href="#or-mapping-s1-4">id</a></dt><dt>4.1.5. <a href="#or-mapping-s1-4b">composite-id</a></dt><dt>4.1.6. <a href="#or-mapping-s1-5">discriminator</a></dt><dt>4.1.7. <a href="#or-mapping-s1-6">version (optional)</a></dt><dt>4.1.8. <a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt>4.1.9. <a href="#or-mapping-s1-7">property</a></dt><dt>4.1.10. <a href="#or-mapping-s1-8">many-to-one</a></dt><dt>4.1.11. <a href="#or-mapping-s1-9">one-to-one</a></dt><dt>4.1.12. <a href="#or-mapping-s1-10">component</a></dt><dt>4.1.13. <a href="#or-mapping-s1-11">subclass</a></dt><dt>4.1.14. <a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt>4.1.15. <a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt>4.2. <a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt>4.2.1. <a href="#or-mapping-s2-1">Entities and values</a></dt><dt>4.2.2. <a href="#or-mapping-s2-2">Basic value types</a></dt><dt>4.2.3. <a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt>4.2.4. <a href="#or-mapping-s2-4">Custom value types</a></dt><dt>4.2.5. <a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt>5.1. <a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-10">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-11">Collection Example</a></dt></dl></dd><dt>5.2. <a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt>6.1. <a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt>6.2. <a href="#manipulating-data-s2">Loading an object</a></dt><dt>6.3. <a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt>6.3.1. <a href="#manipulating-data-s4">Scalar queries</a></dt><dt>6.3.2. <a href="#manipulating-data-s5">The Query interface</a></dt><dt>6.3.3. <a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt>6.3.4. <a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt>6.4. <a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt>6.5. <a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt>6.6. <a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt>6.7. <a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt>6.7.1. <a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt>6.7.2. <a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt>6.8. <a href="#manipulating-data-s12">Flushing</a></dt><dt>6.9. <a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt>6.9.1. <a href="#manipulating-data-s13b">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13b">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13c">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13d">Exception handling</a></dt></dl></dd><dt>6.10. <a href="#manipulating-data-s17">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt>7.1. <a href="#query-language-s1">Case Sensitivity</a></dt><dt>7.2. <a href="#query-language-s2">The from clause</a></dt><dt>7.3. <a href="#query-language-s3">The select clause</a></dt><dt>7.4. <a href="#query-language-s3b">polymorphism</a></dt><dt>7.5. <a href="#query-language-s4">from collections</a></dt><dt>7.6. <a href="#query-language-s5">The where clause</a></dt><dt>7.7. <a href="#query-language-s6">Expressions</a></dt><dt>7.8. <a href="#query-language-s7">The order by clause</a></dt><dt>7.9. <a href="#query-language-s8">The group by clause</a></dt><dt>7.10. <a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt>8.1. <a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt>8.2. <a href="#transactions-s3">Threads and connections</a></dt><dt>8.3. <a href="#transactions-s5">Optimistic Locking / Versioning</a></dt><dd><dl><dt>8.3.1. <a href="#transactions-s5-1">Long session with automatic versioning</a></dt><dt>8.3.2. <a href="#transactions-s5-2">Many sessions with automatic versioning</a></dt><dt>8.3.3. <a href="#transactions-s5-3">Application version checking</a></dt></dl></dd><dt>8.4. <a href="#transactions-s2">Session disconnection</a></dt><dt>8.5. <a href="#transactions-s4">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt>9.1. <a href="#examples-s0">Employer / Employee</a></dt><dt>9.2. <a href="#examples-s1">Author / Work</a></dt><dt>9.3. <a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>1.1. Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> --- 1,5 ---- <html><head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> ! <title>Hibernate Reference Documentation</title><link rel="stylesheet" href="../style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.52.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book"><div class="titlepage"><div><h1 class="title"><a name="d0e1"></a>Hibernate Reference Documentation</h1></div><div><h2 class="subtitle">Relational Persistence for Idiomatic Java</h2></div><div><h2 class="subtitle">http://hibernate.sourceforge.net/</h2></div><hr noshade="true"></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1. <a href="#architecture">Architecture</a></dt><dd><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></dd><dt>2. <a href="#session-configuration">SessionFactory Configuration</a></dt><dd><dl><dt>2.1. <a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt>2.2. <a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt>2.3. <a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt>2.4. <a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt>2.5. <a href="#session-configuration-s5">Other properties</a></dt><dt>2.6. <a href="#session-configuration-s6">XML Configuration File</a></dt><dt>2.7. <a href="#session-configuration-s7">Logging</a></dt></dl></dd><dt>3. <a href="#persistent-classes">Persistent Classes</a></dt><dd><dl><dt>3.1. <a href="#persistent-classes-s1">Simple Example</a></dt><dd><dl><dt>3.1.1. <a href="#persistent-classes-s1-1">Declare accessors and mutators for persistent fields</a></dt><dt>3.1.2. <a href="#persistent-classes-s1-2">Implement a default constructor</a></dt><dt>3.1.3. <a href="#persistent-classes-s1-3">Provide an identifier property (optional)</a></dt></dl></dd><dt>3.2. <a href="#persistent-classes-s2">Inheritance</a></dt><dt>3.3. <a href="#persistent-classes-s3">Persistent Lifecycle Callbacks</a></dt><dt>3.4. <a href="#persistent-classes-s4">Validatable</a></dt></dl></dd><dt>4. <a href="#or-mapping">Basic O/R Mapping</a></dt><dd><dl><dt>4.1. <a href="#or-mapping-s1">Mapping declaration</a></dt><dd><dl><dt>4.1.1. <a href="#or-mapping-s1-1">Doctype</a></dt><dt>4.1.2. <a href="#or-mapping-s1-2">hibernate-mapping</a></dt><dt>4.1.3. <a href="#or-mapping-s1-3">class</a></dt><dt>4.1.4. <a href="#or-mapping-s1-4">id</a></dt><dt>4.1.5. <a href="#or-mapping-s1-4b">composite-id</a></dt><dt>4.1.6. <a href="#or-mapping-s1-5">discriminator</a></dt><dt>4.1.7. <a href="#or-mapping-s1-6">version (optional)</a></dt><dt>4.1.8. <a href="#or-mapping-s1-6b">timestamp (optional)</a></dt><dt>4.1.9. <a href="#or-mapping-s1-7">property</a></dt><dt>4.1.10. <a href="#or-mapping-s1-8">many-to-one</a></dt><dt>4.1.11. <a href="#or-mapping-s1-9">one-to-one</a></dt><dt>4.1.12. <a href="#or-mapping-s1-10">component</a></dt><dt>4.1.13. <a href="#or-mapping-s1-11">subclass</a></dt><dt>4.1.14. <a href="#or-mapping-s1-11b">joined-subclass</a></dt><dt>4.1.15. <a href="#or-mapping-s1-12">map, set, list, bag</a></dt></dl></dd><dt>4.2. <a href="#or-mapping-s2">Hibernate Types</a></dt><dd><dl><dt>4.2.1. <a href="#or-mapping-s2-1">Entities and values</a></dt><dt>4.2.2. <a href="#or-mapping-s2-2">Basic value types</a></dt><dt>4.2.3. <a href="#or-mapping-s2-3">Persistent enum types</a></dt><dt>4.2.4. <a href="#or-mapping-s2-4">Custom value types</a></dt><dt>4.2.5. <a href="#or-mapping-s2-5">The object type</a></dt></dl></dd></dl></dd><dt>5. <a href="#adv-or-mapping">Advanced O/R Mapping</a></dt><dd><dl><dt>5.1. <a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt>5.2. <a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></dd><dt>6. <a href="#manipulating-data">Manipulating Persistent Data</a></dt><dd><dl><dt>6.1. <a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt>6.2. <a href="#manipulating-data-s2">Loading an object</a></dt><dt>6.3. <a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt>6.3.1. <a href="#manipulating-data-s4">Scalar queries</a></dt><dt>6.3.2. <a href="#manipulating-data-s5">The Query interface</a></dt><dt>6.3.3. <a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt>6.3.4. <a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt>6.4. <a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt>6.5. <a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt>6.6. <a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt>6.7. <a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt>6.7.1. <a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt>6.7.2. <a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt>6.8. <a href="#manipulating-data-s12">Flushing</a></dt><dt>6.9. <a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt>6.9.1. <a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13-3">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt>6.10. <a href="#manipulating-data-s14">Interceptors</a></dt></dl></dd><dt>7. <a href="#query-language">Hibernate Query Language</a></dt><dd><dl><dt>7.1. <a href="#query-language-s1">Case Sensitivity</a></dt><dt>7.2. <a href="#query-language-s2">The from clause</a></dt><dt>7.3. <a href="#query-language-s3">The select clause</a></dt><dt>7.4. <a href="#query-language-s3b">polymorphism</a></dt><dt>7.5. <a href="#query-language-s4">from collections</a></dt><dt>7.6. <a href="#query-language-s5">The where clause</a></dt><dt>7.7. <a href="#query-language-s6">Expressions</a></dt><dt>7.8. <a href="#query-language-s7">The order by clause</a></dt><dt>7.9. <a href="#query-language-s8">The group by clause</a></dt><dt>7.10. <a href="#query-language-s9">Subqueries</a></dt></dl></dd><dt>8. <a href="#transactions">Transactions And Concurrency</a></dt><dd><dl><dt>8.1. <a href="#transactions-s1">Datastores, Sessions and Factories</a></dt><dt>8.2. <a href="#transactions-s3">Threads and connections</a></dt><dt>8.3. <a href="#transactions-s5">Optimistic Locking / Versioning</a></dt><dd><dl><dt>8.3.1. <a href="#transactions-s5-1">Long session with automatic versioning</a></dt><dt>8.3.2. <a href="#transactions-s5-2">Many sessions with automatic versioning</a></dt><dt>8.3.3. <a href="#transactions-s5-3">Application version checking</a></dt></dl></dd><dt>8.4. <a href="#transactions-s2">Session disconnection</a></dt><dt>8.5. <a href="#transactions-s4">Pessimistic Locking</a></dt></dl></dd><dt>9. <a href="#examples">Examples</a></dt><dd><dl><dt>9.1. <a href="#examples-s0">Employer / Employee</a></dt><dt>9.2. <a href="#examples-s1">Author / Work</a></dt><dt>9.3. <a href="#examples-s2">Customer / Order / Product</a></dt></dl></dd><dt>10. <a href="#best-practices">Best Practices</a></dt></dl></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="architecture"></a>Chapter 1. Architecture</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>1.1. <a href="#architecture-s1">Overview</a></dt><dt>1.2. <a href="#architecture-s2">Persistent Object Identity</a></dt><dt>1.3. <a href="#architecture-s3">JMX Integration</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="architecture-s1"></a>1.1. Overview</h2></div></div><p> A (very) high-level view of the Hibernate architecture: </p><div class="mediaobject"><img src="../images/overview.gif" align="center"></div><p> *************** *** 88,92 **** a JMX standard MBean but because most application servers do not yet support JMX, Hibernate also affords some non-standard configuration mechanisms. ! </p></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="session-configuration"></a>Chapter 2. SessionFactory Configuration</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>2.1. <a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt>2.2. <a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt>2.3. <a href="#session-configuration-s3">User provided JDBC Connection</a></dt><dt>2.4. <a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt>2.5. <a href="#session-configuration-s5">Other properties</a></dt><dt>2.6. <a href="#session-configuration-s6">XML Configuration File</a></dt><dt>2.7. <a href="#session-configuration-s7">Logging</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="session-configuration-s1"></a>2.1. Programmatic Datastore Configuration</h2></div></div><p> An instance of <tt>cirrus.hibernate.Datastore</tt> represents an entire set of mappings of an application's Java types to a --- 88,92 ---- a JMX standard MBean but because most application servers do not yet support JMX, Hibernate also affords some non-standard configuration mechanisms. ! </p></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="session-configuration"></a>Chapter 2. SessionFactory Configuration</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>2.1. <a href="#session-configuration-s1">Programmatic Datastore Configuration</a></dt><dt>2.2. <a href="#session-configuration-s2">Obtaining a SessionFactory</a></dt><dt>2.3. <a href="#session-configuration-s3">User provided JDBC connection</a></dt><dt>2.4. <a href="#session-configuration-s4">Hibernate provided JDBC connection</a></dt><dt>2.5. <a href="#session-configuration-s5">Other properties</a></dt><dt>2.6. <a href="#session-configuration-s6">XML Configuration File</a></dt><dt>2.7. <a href="#session-configuration-s7">Logging</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="session-configuration-s1"></a>2.1. Programmatic Datastore Configuration</h2></div></div><p> An instance of <tt>cirrus.hibernate.Datastore</tt> represents an entire set of mappings of an application's Java types to a *************** *** 120,124 **** Properties props = new Properties(); ... ! SessionFactory sessions = ds.buildSessionFactory(props);</pre></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="session-configuration-s3"></a>2.3. User provided JDBC Connection</h2></div></div><p> A <tt>SessionFactory</tt> may open a <tt>Session</tt> on a user-provided JDBC connection. This --- 120,124 ---- Properties props = new Properties(); ... ! SessionFactory sessions = ds.buildSessionFactory(props);</pre></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="session-configuration-s3"></a>2.3. User provided JDBC connection</h2></div></div><p> A <tt>SessionFactory</tt> may open a <tt>Session</tt> on a user-provided JDBC connection. This *************** *** 1109,1115 **** <tt>VARCHAR</tt> (or Oracle <tt>VARCHAR2</tt>). </p></dd><br><dt><span class="term"><tt>date, time, timestamp</tt></span></dt><dd><p> ! Type mappings from <tt>java.util.Date</tt> and its subclasses to ! SQL types <tt>DATE</tt>, <tt>TIME</tt> and <tt>TIMESTAMP</tt> (or equivalent). </p></dd><br><dt><span class="term"><tt>big_decimal</tt></span></dt><dd><p> A type mapping from <tt>java.math.BigDecimal</tt> to --- 1109,1119 ---- <tt>VARCHAR</tt> (or Oracle <tt>VARCHAR2</tt>). </p></dd><br><dt><span class="term"><tt>date, time, timestamp</tt></span></dt><dd><p> ! Type mappings from <tt>java.util.Date</tt> and its subclasses ! to SQL types <tt>DATE</tt>, <tt>TIME</tt> and <tt>TIMESTAMP</tt> (or equivalent). + </p></dd><br><dt><span class="term"><tt>calendar, calendar_date</tt></span></dt><dd><p> + Type mappings from <tt>java.util.Calendar</tt> to + SQL types <tt>TIMESTAMP</tt> and <tt>DATE</tt> + (or equivalent). </p></dd><br><dt><span class="term"><tt>big_decimal</tt></span></dt><dd><p> A type mapping from <tt>java.math.BigDecimal</tt> to *************** *** 1206,1210 **** <column name="class_name"/> <column name="id"/> ! </property></pre></div></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="adv-or-mapping"></a>Chapter 5. Advanced O/R Mapping</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1. <a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-10">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-11">Collection Example</a></dt></dl></dd><dt>5.2. <a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s1"></a>5.1. Collections</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-10">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-11">Collection Example</a></dt></dl></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-1"></a>5.1.1. Persistent Collection Styles</h3></div></div><p> This section does not contain much example Java code. We assume you already know how to use Java's collections framework. If so, theres not really anything more --- 1210,1214 ---- <column name="class_name"/> <column name="id"/> ! </property></pre></div></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="adv-or-mapping"></a>Chapter 5. Advanced O/R Mapping</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1. <a href="#adv-or-mapping-s1">Collections</a></dt><dd><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></dd><dt>5.2. <a href="#adv-or-mapping-s2">Components</a></dt><dd><dl><dt>5.2.1. <a href="#adv-or-mapping-s2-1">As Dependent Objects</a></dt><dt>5.2.2. <a href="#adv-or-mapping-s2-2">In Collections</a></dt><dt>5.2.3. <a href="#adv-or-mapping-s2-2b">As a Map Index</a></dt><dt>5.2.4. <a href="#adv-or-mapping-s2-3">As Composite Identifiers</a></dt></dl></dd><dt>5.3. <a href="#adv-or-mapping-s3">Cache</a></dt><dd><dl><dt>5.3.1. <a href="#adv-or-mapping-s3-1">Mapping</a></dt><dt>5.3.2. <a href="#adv-or-mapping-s3-2">Read Only Cache</a></dt><dt>5.3.3. <a href="#adv-or-mapping-s3-3">Read / Write Cache</a></dt></dl></dd><dt>5.4. <a href="#adv-or-mapping-s4">Proxies for Lazy Initialization</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="adv-or-mapping-s1"></a>5.1. Collections</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>5.1.1. <a href="#adv-or-mapping-s1-1">Persistent Collection Styles</a></dt><dt>5.1.2. <a href="#adv-or-mapping-s1-2">Toplevel and Nested Collections</a></dt><dt>5.1.3. <a href="#adv-or-mapping-s1-3">Mapping a Collection</a></dt><dt>5.1.4. <a href="#adv-or-mapping-s1-4">Mapping a Property to a Toplevel Collection</a></dt><dt>5.1.5. <a href="#adv-or-mapping-s1-5">Collections of Values and Many To Many Associations</a></dt><dt>5.1.6. <a href="#adv-or-mapping-s1-6">One To Many Associations</a></dt><dt>5.1.7. <a href="#adv-or-mapping-s1-7">Lazy Initialization</a></dt><dt>5.1.8. <a href="#adv-or-mapping-s1-8">Sorted Collections</a></dt><dt>5.1.9. <a href="#adv-or-mapping-s1-9">Garbage Collection</a></dt><dt>5.1.10. <a href="#adv-or-mapping-s1-10">Bidirectional Associations</a></dt><dt>5.1.11. <a href="#adv-or-mapping-s1-11">Ternary Associations</a></dt><dt>5.1.12. <a href="#adv-or-mapping-s1-12">Collection Example</a></dt></dl></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-1"></a>5.1.1. Persistent Collection Styles</h3></div></div><p> This section does not contain much example Java code. We assume you already know how to use Java's collections framework. If so, theres not really anything more *************** *** 1532,1536 **** .... <many-to-one name="parent" class="eg.Parent" column="parent_id"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-10"></a>5.1.11. Ternary Associations</h3></div></div><p> There are two possible approaches to mapping a ternary association. One approach is to use composite elements (discussed below). Another is to use a <tt>Map</tt> with an --- 1536,1540 ---- .... <many-to-one name="parent" class="eg.Parent" column="parent_id"/> ! </class></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-11"></a>5.1.11. Ternary Associations</h3></div></div><p> There are two possible approaches to mapping a ternary association. One approach is to use composite elements (discussed below). Another is to use a <tt>Map</tt> with an *************** *** 1544,1548 **** <index-many-to-many column="node2_id" class="Node"/> <many-to-many column="connection_id" class="Connection"/> ! </map></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-11"></a>5.1.12. Collection Example</h3></div></div><p> The previous sections are pretty confusing. So lets look at an example. This class: --- 1548,1552 ---- <index-many-to-many column="node2_id" class="Node"/> <many-to-many column="connection_id" class="Connection"/> ! </map></pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="adv-or-mapping-s1-12"></a>5.1.12. Collection Example</h3></div></div><p> The previous sections are pretty confusing. So lets look at an example. This class: *************** *** 1968,1972 **** Exceptions that occur while initializing a proxy are wrapped in a <tt>LazyInitializationException</tt>. ! </p></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="manipulating-data"></a>Chapter 6. Manipulating Persistent Data</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>6.1. <a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt>6.2. <a href="#manipulating-data-s2">Loading an object</a></dt><dt>6.3. <a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt>6.3.1. <a href="#manipulating-data-s4">Scalar queries</a></dt><dt>6.3.2. <a href="#manipulating-data-s5">The Query interface</a></dt><dt>6.3.3. <a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt>6.3.4. <a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt>6.4. <a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt>6.5. <a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt>6.6. <a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt>6.7. <a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt>6.7.1. <a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt>6.7.2. <a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt>6.8. <a href="#manipulating-data-s12">Flushing</a></dt><dt>6.9. <a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt>6.9.1. <a href="#manipulating-data-s13b">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13b">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13c">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13d">Exception handling</a></dt></dl></dd><dt>6.10. <a href="#manipulating-data-s17">Interceptors</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s1"></a>6.1. Creating a persistent object</h2></div></div><p> An object (entity instance) is either <span class="emphasis"><em>transient</em></span> or <span class="emphasis"><em>persistent</em></span> with respect to a particular --- 1972,1976 ---- Exceptions that occur while initializing a proxy are wrapped in a <tt>LazyInitializationException</tt>. ! </p></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="manipulating-data"></a>Chapter 6. Manipulating Persistent Data</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>6.1. <a href="#manipulating-data-s1">Creating a persistent object</a></dt><dt>6.2. <a href="#manipulating-data-s2">Loading an object</a></dt><dt>6.3. <a href="#manipulating-data-s3">Querying</a></dt><dd><dl><dt>6.3.1. <a href="#manipulating-data-s4">Scalar queries</a></dt><dt>6.3.2. <a href="#manipulating-data-s5">The Query interface</a></dt><dt>6.3.3. <a href="#manipulating-data-s5b">Scrollable iteration</a></dt><dt>6.3.4. <a href="#manipulating-data-s6">Filtering collections</a></dt></dl></dd><dt>6.4. <a href="#manipulating-data-s7">Updating objects saved or loaded in the current session</a></dt><dt>6.5. <a href="#manipulating-data-s8">Updating objects saved or loaded in a previous session</a></dt><dt>6.6. <a href="#manipulating-data-s9">Deleting persistent objects</a></dt><dt>6.7. <a href="#manipulating-data-s10">Graphs of objects</a></dt><dd><dl><dt>6.7.1. <a href="#manipulating-data-s11a">Lifecycle objects</a></dt><dt>6.7.2. <a href="#manipulating-data-s11b">Persistence by Reachability</a></dt></dl></dd><dt>6.8. <a href="#manipulating-data-s12">Flushing</a></dt><dt>6.9. <a href="#manipulating-data-s13">Ending a Session</a></dt><dd><dl><dt>6.9.1. <a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13-3">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></dd><dt>6.10. <a href="#manipulating-data-s14">Interceptors</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s1"></a>6.1. Creating a persistent object</h2></div></div><p> An object (entity instance) is either <span class="emphasis"><em>transient</em></span> or <span class="emphasis"><em>persistent</em></span> with respect to a particular *************** *** 2386,2390 **** performance of some transactions. However, the session is now very clever about when it flushes before queries. ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s13"></a>6.9. Ending a Session</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>6.9.1. <a href="#manipulating-data-s13b">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13b">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13c">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13d">Exception handling</a></dt></dl></div><p> Ending a session involves four distinct phases: </p><div class="itemizedlist"><ul type="disc"><li><p> --- 2390,2394 ---- performance of some transactions. However, the session is now very clever about when it flushes before queries. ! </p></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s13"></a>6.9. Ending a Session</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>6.9.1. <a href="#manipulating-data-s13-1">Flushing the session</a></dt><dt>6.9.2. <a href="#manipulating-data-s13-2">Committing the transaction</a></dt><dt>6.9.3. <a href="#manipulating-data-s13-3">Closing the session</a></dt><dt>6.9.4. <a href="#manipulating-data-s13-4">Exception handling</a></dt></dl></div><p> Ending a session involves four distinct phases: </p><div class="itemizedlist"><ul type="disc"><li><p> *************** *** 2396,2436 **** </p></li><li><p> handle exceptions ! </p></li></ul></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13b"></a>6.9.1. Flushing the session</h3></div></div><p> ! If you happen to be using the <tt>Transaction</tt> API, you don't ! need to worry about this step. It will be performed implicitly when the ! transaction is committed. Otherwise you should call ! <tt>Session.flush()</tt> to ensure that all changes are synchronized ! with the database. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13b"></a>6.9.2. Committing the transaction</h3></div></div><p> ! If you are using the Hibernate <tt>Transaction</tt> API, this looks like: ! </p><pre class="programlisting">tx.commit(); // flush the Session and commit the transaction</pre><p> ! If you are managing JDBC transactions yourself you should manually ! <tt>commit()</tt> the JDBC connection. ! </p><pre class="programlisting">sess.flush(); sess.connection().commit(); //not necessary for JTA datasource</pre><p> ! If you decide <span class="emphasis"><em>not</em></span> to commit your changes: ! </p><pre class="programlisting">tx.rollback(); // rollback the transaction</pre><p> ! or: ! </p><pre class="programlisting">//not necessary for JTA datasource, important otherwise ! sess.connection().rollback();</pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13c"></a>6.9.3. Closing the session</h3></div></div><p> ! A call to <tt>Session.close()</tt> marks the end of a session. The main implication ! of <tt>close()</tt> is that the JDBC connection will be relinquished by the session. ! </p><pre class="programlisting">tx.commit(); sess.close();</pre><pre class="programlisting">sess.flush(); sess.connection().commit(); //not necessary for JTA datasource sess.close();</pre><p> ! If you provided your own connection, <tt>close()</tt> returns a reference ! to it, so you can manually close it or return it to the pool. Otherwise <tt>close() ! </tt> returns it to the pool. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13d"></a>6.9.4. Exception handling</h3></div></div><p> ! If the <tt>Session</tt> throws an exception (including ! any <tt>SQLException</tt>), you should immediately ! rollback the transaction, call <tt>Session.close()</tt> ! and discard the <tt>Session</tt> instance. Certain ! methods of <tt>Session</tt> will <span class="emphasis"><em>not</em></span> ! leave the session in a consistent state. ! </p><p> ! The following exception handling idiom is recommended: ! </p><pre class="programlisting">Session sess = factory.openSession(); Transaction tx = null; try { --- 2400,2440 ---- </p></li><li><p> handle exceptions ! </p></li></ul></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13-1"></a>6.9.1. Flushing the session</h3></div></div><p> ! If you happen to be using the <tt>Transaction</tt> API, you don't ! need to worry about this step. It will be performed implicitly when the ! transaction is committed. Otherwise you should call ! <tt>Session.flush()</tt> to ensure that all changes are synchronized ! with the database. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13-2"></a>6.9.2. Committing the transaction</h3></div></div><p> ! If you are using the Hibernate <tt>Transaction</tt> API, this looks like: ! </p><pre class="programlisting">tx.commit(); // flush the Session and commit the transaction</pre><p> ! If you are managing JDBC transactions yourself you should manually ! <tt>commit()</tt> the JDBC connection. ! </p><pre class="programlisting">sess.flush(); sess.connection().commit(); //not necessary for JTA datasource</pre><p> ! If you decide <span class="emphasis"><em>not</em></span> to commit your changes: ! </p><pre class="programlisting">tx.rollback(); // rollback the transaction</pre><p> ! or: ! </p><pre class="programlisting">//not necessary for JTA datasource, important otherwise ! sess.connection().rollback();</pre></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13-3"></a>6.9.3. Closing the session</h3></div></div><p> ! A call to <tt>Session.close()</tt> marks the end of a session. The main implication ! of <tt>close()</tt> is that the JDBC connection will be relinquished by the session. ! </p><pre class="programlisting">tx.commit(); sess.close();</pre><pre class="programlisting">sess.flush(); sess.connection().commit(); //not necessary for JTA datasource sess.close();</pre><p> ! If you provided your own connection, <tt>close()</tt> returns a reference ! to it, so you can manually close it or return it to the pool. Otherwise <tt>close() ! </tt> returns it to the pool. ! </p></div><div class="sect2"><div class="titlepage"><div><h3 class="title"><a name="manipulating-data-s13-4"></a>6.9.4. Exception handling</h3></div></div><p> ! If the <tt>Session</tt> throws an exception (including ! any <tt>SQLException</tt>), you should immediately ! rollback the transaction, call <tt>Session.close()</tt> ! and discard the <tt>Session</tt> instance. Certain ! methods of <tt>Session</tt> will <span class="emphasis"><em>not</em></span> ! leave the session in a consistent state. ! </p><p> ! The following exception handling idiom is recommended: ! </p><pre class="programlisting">Session sess = factory.openSession(); Transaction tx = null; try { *************** *** 2447,2452 **** sess.close(); }</pre><p> ! Or, when manually managing JDBC transactions: ! </p><pre class="programlisting">Session sess = factory.openSession(); try { //do some work --- 2451,2456 ---- sess.close(); }</pre><p> ! Or, when manually managing JDBC transactions: ! </p><pre class="programlisting">Session sess = factory.openSession(); try { //do some work *************** *** 2462,2467 **** sess.close(); }</pre><p> ! Or, when using a datasource enlisted with JTA: ! </p><pre class="programlisting">UserTransaction ut = .... ; Session sess = factory.openSession(); try { --- 2466,2471 ---- sess.close(); }</pre><p> ! Or, when using a datasource enlisted with JTA: ! </p><pre class="programlisting">UserTransaction ut = .... ; Session sess = factory.openSession(); try { *************** *** 2476,2489 **** finally { sess.close(); ! }</pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s17"></a>6.10. Interceptors</h2></div></div><p> ! The <tt>Interceptor</tt> interface provides callbacks from the session to the ! application allowing the application to inspect and / or manipulate properties of a ! persistent object before it is saved, updated or deleted and after it is loaded. One ! possible use for this is to track auditing information. For example, the following ! <tt>Interceptor</tt> automatically sets the <tt>createTimestamp</tt> ! when an <tt>Auditable</tt> is created and updates the ! <tt>lastUpdateTimestamp</tt> property when an <tt>Auditable</tt> is ! updated. ! </p></div><pre class="programlisting">package cirrus.hibernate.test; import java.io.Serializable; --- 2480,2493 ---- finally { sess.close(); ! }</pre></div></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="manipulating-data-s14"></a>6.10. Interceptors</h2></div></div><p> ! The <tt>Interceptor</tt> interface provides callbacks from the session to the ! application allowing the application to inspect and / or manipulate properties of a ! persistent object before it is saved, updated or deleted and after it is loaded. One ! possible use for this is to track auditing information. For example, the following ! <tt>Interceptor</tt> automatically sets the <tt>createTimestamp</tt> ! when an <tt>Auditable</tt> is created and updates the ! <tt>lastUpdateTimestamp</tt> property when an <tt>Auditable</tt> is ! updated. ! </p><pre class="programlisting">package cirrus.hibernate.test; import java.io.Serializable; *************** *** 2543,2548 **** }</pre><p> ! The interceptor would be specified when a session is created. ! </p><pre class="programlisting">Session session = sf.openSession( new AuditInterceptor() );</pre></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="query-language"></a>Chapter 7. Hibernate Query Language</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>7.1. <a href="#query-language-s1">Case Sensitivity</a></dt><dt>7.2. <a href="#query-language-s2">The from clause</a></dt><dt>7.3. <a href="#query-language-s3">The select clause</a></dt><dt>7.4. <a href="#query-language-s3b">polymorphism</a></dt><dt>7.5. <a href="#query-language-s4">from collections</a></dt><dt>7.6. <a href="#query-language-s5">The where clause</a></dt><dt>7.7. <a href="#query-language-s6">Expressions</a></dt><dt>7.8. <a href="#query-language-s7">The order by clause</a></dt><dt>7.9. <a href="#query-language-s8">The group by clause</a></dt><dt>7.10. <a href="#query-language-s9">Subqueries</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="query-language-s1"></a>7.1. Case Sensitivity</h2></div></div><p> Queries are case-insensitive, except for names of Java classes and properties. So <tt>SeLeCT</tt> is the same as --- 2547,2552 ---- }</pre><p> ! The interceptor would be specified when a session is created. ! </p><pre class="programlisting">Session session = sf.openSession( new AuditInterceptor() );</pre></div></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="query-language"></a>Chapter 7. Hibernate Query Language</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt>7.1. <a href="#query-language-s1">Case Sensitivity</a></dt><dt>7.2. <a href="#query-language-s2">The from clause</a></dt><dt>7.3. <a href="#query-language-s3">The select clause</a></dt><dt>7.4. <a href="#query-language-s3b">polymorphism</a></dt><dt>7.5. <a href="#query-language-s4">from collections</a></dt><dt>7.6. <a href="#query-language-s5">The where clause</a></dt><dt>7.7. <a href="#query-language-s6">Expressions</a></dt><dt>7.8. <a href="#query-language-s7">The order by clause</a></dt><dt>7.9. <a href="#query-language-s8">The group by clause</a></dt><dt>7.10. <a href="#query-language-s9">Subqueries</a></dt></dl></div><div class="sect1"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="query-language-s1"></a>7.1. Case Sensitivity</h2></div></div><p> Queries are case-insensitive, except for names of Java classes and properties. So <tt>SeLeCT</tt> is the same as *************** *** 3159,3163 **** <id name="id" column="id"> ! <generator class="native"/> </id> --- 3163,3167 ---- <id name="id" column="id"> ! <generator class="assigned"/> <!-- The Author must have the same identifier as the Person --> </id> |