From: <tu...@us...> - 2003-02-23 13:53:28
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv19045/doc/reference/src Modified Files: advanced_or_mapping.xml architecture.xml basic_or_mapping.xml best_practices.xml examples.xml index.xml manipulating_data.xml persistent_classes.xml query_language.xml session_configuration.xml transactions.xml Log Message: Updated for new XSL stylesheets Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** advanced_or_mapping.xml 28 Jan 2003 13:25:10 -0000 1.9 --- advanced_or_mapping.xml 23 Feb 2003 13:53:24 -0000 1.10 *************** *** 115,122 **** </para> ! <programlisting><![CDATA[<map name="propertyName" table="table_name" ! schema="schema_name lazy="true|false" inverse="true|false" --- 115,133 ---- </para> ! <programlistingco> ! <areaspec> ! <area id="mappingcollection1" coords="2 50"/> ! <area id="mappingcollection2" coords="3 50"/> ! <area id="mappingcollection3" coords="4 50"/> ! <area id="mappingcollection4" coords="5 50"/> ! <area id="mappingcollection5" coords="6 50"/> ! <area id="mappingcollection6" coords="7 50"/> ! <area id="mappingcollection7" coords="8 50"/> ! <area id="mappingcollection8" coords="9 50"/> ! </areaspec> ! <programlisting><![CDATA[<map name="propertyName" table="table_name" ! schema="schema_name" lazy="true|false" inverse="true|false" *************** *** 129,184 **** <element .... /> </map>]]></programlisting> ! ! <itemizedlist> ! <listitem> ! <para> ! <literal>name</literal> the collection property name ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>table</literal> (optional - defaults to property name) the ! name of the collection table (not used for one-to-many associations) ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>schema</literal> (optional) the name of a table schema to ! override the schema declared on the root element ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>lazy</literal> (optional - defaults to <literal>false</literal>) ! enable lazy initialization (not used for arrays) ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>inverse</literal> (optional - defaults to <literal>false</literal>) ! mark this collection as the "inverse" end of a bidirectional association ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>cascade</literal> (optional - defaults to <literal>none</literal>) ! enable operations to cascade to child entities (not used for toplevel ! collections) ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>sort</literal> (optional) specify a sorted collection with ! <literal>natural</literal> sort order, or a given comparator class ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>order-by</literal> (optional, JDK1.4 only) specify a table column (or columns) ! that define the iteration order of the <literal>Map</literal>, <literal>Set</literal> ! or bag, together with an optional <literal>asc</literal> or <literal>desc</literal>. ! </para> ! </listitem> ! </itemizedlist> </sect2> --- 140,196 ---- <element .... /> </map>]]></programlisting> ! <calloutlist> ! <callout arearefs="mappingcollection1"> ! <para> ! <literal>name</literal> the collection property name ! </para> ! </callout> ! <callout arearefs="mappingcollection2"> ! <para> ! <literal>table</literal> (optional - defaults to property name) the ! name of the collection table (not used for one-to-many associations) ! </para> ! </callout> ! <callout arearefs="mappingcollection3"> ! <para> ! <literal>schema</literal> (optional) the name of a table schema to ! override the schema declared on the root element ! </para> ! </callout> ! <callout arearefs="mappingcollection4"> ! <para> ! <literal>lazy</literal> (optional - defaults to <literal>false</literal>) ! enable lazy initialization (not used for arrays) ! </para> ! </callout> ! <callout arearefs="mappingcollection5"> ! <para> ! <literal>inverse</literal> (optional - defaults to <literal>false</literal>) ! mark this collection as the "inverse" end of a bidirectional association ! </para> ! </callout> ! <callout arearefs="mappingcollection6"> ! <para> ! <literal>cascade</literal> (optional - defaults to <literal>none</literal>) ! enable operations to cascade to child entities (not used for toplevel ! collections) ! </para> ! </callout> ! <callout arearefs="mappingcollection7"> ! <para> ! <literal>sort</literal> (optional) specify a sorted collection with ! <literal>natural</literal> sort order, or a given comparator class ! </para> ! </callout> ! <callout arearefs="mappingcollection8"> ! <para> ! <literal>order-by</literal> (optional, JDK1.4 only) specify a table column (or columns) ! that define the iteration order of the <literal>Map</literal>, <literal>Set</literal> ! or bag, together with an optional <literal>asc</literal> or <literal>desc</literal>. ! </para> ! </callout> ! </calloutlist> ! </programlistingco> ! </sect2> *************** *** 270,274 **** </para> ! <itemizedlist> <listitem> <para> --- 282,286 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 330,334 **** <programlisting><![CDATA[s = sessions.openSession(); ! User u = (User)s.find("from user in illflow.User where user.Name=?", userName, Hibernate.STRING).get(0); Map permissions = u.getPermissions(); s.connection().commit(); --- 342,348 ---- <programlisting><![CDATA[s = sessions.openSession(); ! User u = (User)s.find("from user in illflow.User where user.Name=?", ! userName, ! Hibernate.STRING).get(0); Map permissions = u.getPermissions(); s.connection().commit(); *************** *** 417,441 **** "ends" of the association. Two kinds of bidirectional association are supported: - </para> - - <variablelist> - <varlistentry> - <term>one-to-many</term> - <listitem> - <para> - Set valued at one end, single-valued at the other - </para> - </listitem> - </varlistentry> - <varlistentry> - <term>many-to-many</term> - <listitem> - <para> - Set / bag valued at both ends - </para> - </listitem> - </varlistentry> - </variablelist> <para> You may specify a bidirectional many-to-many association simply by mapping two --- 431,456 ---- "ends" of the association. Two kinds of bidirectional association are supported: + <variablelist> + <varlistentry> + <term>one-to-many</term> + <listitem> + <para> + Set valued at one end, single-valued at the other + </para> + </listitem> + </varlistentry> + <varlistentry> + <term>many-to-many</term> + <listitem> + <para> + Set/bag valued at both ends + </para> + </listitem> + </varlistentry> + </variablelist> + + </para> + <para> You may specify a bidirectional many-to-many association simply by mapping two *************** *** 452,456 **** <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <bag name="accessibleFrom" table="node_access" inverse="true" lazy="true"> <!-- inverse end --> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> --- 467,472 ---- <many-to-many class="eg.Node" column="from_node_id"/> </bag> ! <!-- inverse end --> ! <bag name="accessibleFrom" table="node_access" inverse="true" lazy="true"> <key column="from_node_id"/> <many-to-many class="eg.Node" column="to_node_id"/> *************** *** 773,777 **** <property name="price"/> <property name="quantity"/> ! <many-to-one name="item" class="eg.Item/> <!--class attribute is optional--> </composite-element> </set> --- 789,793 ---- <property name="price"/> <property name="quantity"/> ! <many-to-one name="item" class="eg.Item"/> <!-- class attribute is optional --> </composite-element> </set> *************** *** 786,790 **** <composite-element class="eg.OrderLine"> <many-to-one name="purchaseDetails class="eg.Purchase"/> ! <many-to-one name="item" class="eg.Item/> </composite-element> </set> --- 802,806 ---- <composite-element class="eg.OrderLine"> <many-to-one name="purchaseDetails class="eg.Purchase"/> ! <many-to-one name="item" class="eg.Item"/> </composite-element> </set> *************** *** 814,818 **** </para> ! <itemizedlist> <listitem> <para> --- 830,834 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 952,967 **** </para> - <programlisting><![CDATA[<jcs-cache usage="read-write|read-only"/>]]></programlisting> - - <itemizedlist> - <listitem> - <para> - <literal>usage</literal> specifies the caching strategy - (<literal>read-write</literal>, - <literal>read-only</literal>) - </para> - </listitem> - </itemizedlist> </sect2> --- 968,987 ---- </para> + <programlistingco> + <areaspec> + <area id="cache1" coords="1 40"/> + </areaspec> + <programlisting><![CDATA[<jcs-cache usage="read-write|read-only" />]]></programlisting> + <calloutlist> + <callout arearefs="cache1"> + <para> + <literal>usage</literal> specifies the caching strategy + (<literal>read-write</literal>, + <literal>read-only</literal>) + </para> + </callout> + </calloutlist> + </programlistingco> </sect2> *************** *** 1053,1059 **** </para> ! <programlisting><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); //instantiate a proxy (does not hit the db) ! if ( cat.isDomesticCat() ) { //hit the db to initialize the proxy ! DomesticCat dc = (DomesticCat) cat; // Error! .... }]]></programlisting> --- 1073,1079 ---- </para> ! <programlisting><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a proxy (does not hit the db) ! if ( cat.isDomesticCat() ) { // hit the db to initialize the proxy ! DomesticCat dc = (DomesticCat) cat; // Error! .... }]]></programlisting> *************** *** 1063,1069 **** </para> ! <programlisting><![CDATA[Cat cat = (Cat) session.load(Cat.class, id); //instantiate a Cat proxy ! DomesticCat dc = (DomesticCat) session.load(DomesticCat.class, id); //must instantiate a new DomesticCat proxy! ! System.out.println(cat==dc); //false]]></programlisting> <para> --- 1083,1091 ---- </para> ! <programlisting><![CDATA[ ! Cat cat = (Cat) session.load(Cat.class, id); // instantiate a Cat proxy ! DomesticCat dc = ! (DomesticCat) session.load(DomesticCat.class, id); // required new DomesticCat proxy! ! System.out.println(cat==dc); // false]]></programlisting> <para> *************** *** 1072,1077 **** </para> ! <programlisting><![CDATA[cat.setWeight(11.0); //hit the db to initialize the proxy ! System.out.println( dc.getWeight() ); //11.0]]></programlisting> <para> --- 1094,1099 ---- </para> ! <programlisting><![CDATA[cat.setWeight(11.0); // hit the db to initialize the proxy ! System.out.println( dc.getWeight() ); // 11.0]]></programlisting> <para> *************** *** 1115,1119 **** </para> ! <itemizedlist> <listitem> <para> --- 1137,1141 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> Index: architecture.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/architecture.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** architecture.xml 1 Jan 2003 13:46:23 -0000 1.1.1.1 --- architecture.xml 23 Feb 2003 13:53:24 -0000 1.2 *************** *** 5,9 **** <sect1 id="architecture-s1"> <title>Overview</title> ! <para> A (very) high-level view of the Hibernate architecture: --- 5,9 ---- <sect1 id="architecture-s1"> <title>Overview</title> ! <para> A (very) high-level view of the Hibernate architecture: *************** *** 11,18 **** <mediaobject> ! <imageobject> ! <imagedata fileref="images/overview.pdf" format="EPS" align="center"/> </imageobject> ! <imageobject> <imagedata fileref="../images/overview.gif" format="GIF" align="center"/> </imageobject> --- 11,18 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/overview.svg" format="SVG" align="center"/> </imageobject> ! <imageobject role="html"> <imagedata fileref="../images/overview.gif" format="GIF" align="center"/> </imageobject> *************** *** 33,40 **** <mediaobject> ! <imageobject> ! <imagedata fileref="images/lite.pdf" format="EPS" align="center"/> </imageobject> ! <imageobject> <imagedata fileref="../images/lite.gif" format="GIF" align="center"/> </imageobject> --- 33,40 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/lite.svg" format="SVG" align="center"/> </imageobject> ! <imageobject role="html"> <imagedata fileref="../images/lite.gif" format="GIF" align="center"/> </imageobject> *************** *** 47,54 **** <mediaobject> ! <imageobject> ! <imagedata fileref="images/full_cream.pdf" format="EPS" align="center"/> </imageobject> ! <imageobject> <imagedata fileref="../images/full_cream.gif" format="GIF" align="center"/> </imageobject> --- 47,54 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/full_cream.svg" format="SVG" align="center"/> </imageobject> ! <imageobject role="html"> <imagedata fileref="../images/full_cream.gif" format="GIF" align="center"/> </imageobject> *************** *** 57,174 **** <para> Heres some definitions of the objects in the diagrams: - </para> - - <itemizedlist> - <listitem> - <para> - <literal>net.sf.hibernate.SessionFactory</literal> - </para> - </listitem> - <listitem> - <para> - <literal>net.sf.hibernate.Session</literal> - </para> - </listitem> - <listitem> - <para> - <literal>net.sf.hibernate.Transaction</literal> - </para> - </listitem> - <listitem> - <para> - <literal>net.sf.hibernate.TransactionFactory</literal> - </para> - </listitem> - <listitem> - <para> - <literal>net.sf.hibernate.connection.ConnectionProvider</literal> - </para> - </listitem> - <listitem> - <para> - persistent objects and collections - </para> - </listitem> - <listitem> - <para> - transient objects and collections - </para> - </listitem> - </itemizedlist> ! <variablelist> ! <varlistentry> ! <term>SessionFactory</term> ! <listitem> ! <para> ! A threadsafe (immutable) cache of compiled mappings. A factory for ! <literal>Session</literal>. A client of <literal>ConnectionProvider</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Session</term> ! <listitem> ! <para> ! A single-threaded, short-lived object representing a conversation between ! the application and the persistent store. Wraps a JDBC connection. Factory ! for <literal>Transaction</literal>. Manages persistent objects to the ! application. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Persistent Objects and Collections</term> ! <listitem> ! <para> ! Short-lived, single threaded objects containing persistent state and business ! function. These might be ordinary JavaBeans, the only special thing about them ! is that they are currently associated with (exactly one) ! <literal>Session</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Transient Objects and Collections</term> ! <listitem> ! <para> ! Instances of persistent classes that are not currently associated with a ! <literal>Session</literal>. They may have been instantiated by ! the application and not (yet) persisted or they may have been instantiated by a ! closed <literal>Session</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Transaction</term> ! <listitem> ! <para> ! ( Optional ) A single-threaded, short-lived object used by the application to ! specify atomic units of work. Abstracts application from underlying JDBC, ! JTA or CORBA transaction. A <literal>Session</literal> might span several ! <literal>Transaction</literal>s. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>ConnectionProvider</term> ! <listitem> ! <para> ! ( Optional ) A factory for JDBC connections. Abstracts application from ! underlying <literal>Datasource</literal> or <literal>DriverManager</literal>. ! Not exposed to application. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>TransactionFactory</term> ! <listitem> ! <para> ! ( Optional ) A factory for <literal>Transaction</literal>. Not exposed to the ! application. ! </para> ! </listitem> ! </varlistentry> ! </variablelist> <para> --- 57,136 ---- <para> Heres some definitions of the objects in the diagrams: ! <variablelist spacing="compact"> ! <varlistentry> ! <term>SessionFactory (<literal>net.sf.hibernate.SessionFactory</literal>)</term> ! <listitem> ! <para> ! A threadsafe (immutable) cache of compiled mappings. A factory for ! <literal>Session</literal>. A client of <literal>ConnectionProvider</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Session (<literal>net.sf.hibernate.Session</literal>)</term> ! <listitem> ! <para> ! A single-threaded, short-lived object representing a conversation between ! the application and the persistent store. Wraps a JDBC connection. Factory ! for <literal>Transaction</literal>. Manages persistent objects to the ! application. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Persistent Objects and Collections</term> ! <listitem> ! <para> ! Short-lived, single threaded objects containing persistent state and business ! function. These might be ordinary JavaBeans, the only special thing about them ! is that they are currently associated with (exactly one) ! <literal>Session</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Transient Objects and Collections</term> ! <listitem> ! <para> ! Instances of persistent classes that are not currently associated with a ! <literal>Session</literal>. They may have been instantiated by ! the application and not (yet) persisted or they may have been instantiated by a ! closed <literal>Session</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>Transaction (<literal>net.sf.hibernate.Transaction</literal>)</term> ! <listitem> ! <para> ! (Optional) A single-threaded, short-lived object used by the application to ! specify atomic units of work. Abstracts application from underlying JDBC, ! JTA or CORBA transaction. A <literal>Session</literal> might span several ! <literal>Transaction</literal>s. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>ConnectionProvider (<literal>net.sf.hibernate.connection.ConnectionProvider</literal>)</term> ! <listitem> ! <para> ! (Optional) A factory for JDBC connections. Abstracts application from ! underlying <literal>Datasource</literal> or <literal>DriverManager</literal>. ! Not exposed to application. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>TransactionFactory (<literal>net.sf.hibernate.TransactionFactory</literal>)</term> ! <listitem> ! <para> ! (Optional) A factory for <literal>Transaction</literal>. Not exposed to the ! application. ! </para> ! </listitem> ! </varlistentry> ! </variablelist> ! </para> <para> *************** *** 189,202 **** </para> ! <simplelist type="horiz" columns="2"> ! <member>Persistent Identity</member> ! <member> ! <literal>foo.getId().equals( bar.getId() )</literal> ! </member> ! <member>JVM Identity</member> ! <member> ! <literal>foo==bar</literal> ! </member> ! </simplelist> <para> --- 151,172 ---- </para> ! <variablelist spacing="compact"> ! <varlistentry> ! <term>Persistent Identity</term> ! <listitem> ! <para> ! <literal>foo.getId().equals( bar.getId() )</literal> ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term>JVM Identity</term> ! <listitem> ! <para> ! <literal>foo==bar</literal> ! </para> ! </listitem> ! </varlistentry> ! </variablelist> <para> Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** basic_or_mapping.xml 16 Feb 2003 04:09:28 -0000 1.8 --- basic_or_mapping.xml 23 Feb 2003 13:53:24 -0000 1.9 *************** *** 85,91 **** <para> ! You may declare a persistent class using </para> ! <programlisting><![CDATA[<class name="ClassName" table="tableName" --- 85,104 ---- <para> [...1528 lines suppressed...] ! to a basic type or implement <literal>PersistentEnum</literal>. ! </para> ! </listitem> ! </varlistentry> ! <varlistentry> ! <term><literal>clob, blob</literal></term> ! <listitem> ! <para> ! Type mappings for the JDBC classes <literal>java.sql.Clob</literal> and ! <literal>java.sql.Blob</literal>. These types may be inconvenient for some ! applications, since the blob or clob object may not be reused outside of ! a transaction. (Furthermore, driver support is patchy and inconsistent.) ! </para> ! </listitem> ! </varlistentry> ! </variablelist> ! ! </para> <para> Index: best_practices.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/best_practices.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** best_practices.xml 1 Jan 2003 13:46:28 -0000 1.1.1.1 --- best_practices.xml 23 Feb 2003 13:53:24 -0000 1.2 *************** *** 3,7 **** <title>Best Practices</title> ! <variablelist> <varlistentry> <term>Write fine-grained classes and map them using <literal><component></literal> --- 3,7 ---- <title>Best Practices</title> ! <variablelist spacing="compact"> <varlistentry> <term>Write fine-grained classes and map them using <literal><component></literal> Index: examples.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/examples.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** examples.xml 16 Jan 2003 08:39:24 -0000 1.3 --- examples.xml 23 Feb 2003 13:53:24 -0000 1.4 *************** *** 4,8 **** <sect1 id="examples-s0"> ! <title>Employer / Employee</title> <para> --- 4,8 ---- <sect1 id="examples-s0"> ! <title>Employer/Employee</title> <para> *************** *** 15,19 **** <mediaobject> ! <imageobject> <imagedata fileref="../images/EmployerEmployee.gif" format="GIF" align="center"/> </imageobject> --- 15,22 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/EmployerEmployee.gif" format="GIF" align="center"/> ! </imageobject> ! <imageobject role="html"> <imagedata fileref="../images/EmployerEmployee.gif" format="GIF" align="center"/> </imageobject> *************** *** 103,108 **** ) ! alter table employment_periods add constraint employment_periodsFK0 foreign key (employer_id) references employers ! alter table employment_periods add constraint employment_periodsFK1 foreign key (employee_id) references employees create sequence employee_id_seq create sequence employment_id_seq --- 106,113 ---- ) ! alter table employment_periods ! add constraint employment_periodsFK0 foreign key (employer_id) references employers ! alter table employment_periods ! add constraint employment_periodsFK1 foreign key (employee_id) references employees create sequence employee_id_seq create sequence employment_id_seq *************** *** 112,116 **** <sect1 id="examples-s1"> ! <title>Author / Work</title> <para> --- 117,121 ---- <sect1 id="examples-s1"> ! <title>Author/Work</title> <para> *************** *** 124,128 **** <mediaobject> ! <imageobject> <imagedata fileref="../images/AuthorWork.gif" format="GIF" align="center"/> </imageobject> --- 129,136 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/AuthorWork.gif" format="GIF" align="center"/> ! </imageobject> ! <imageobject role="html"> <imagedata fileref="../images/AuthorWork.gif" format="GIF" align="center"/> </imageobject> *************** *** 162,166 **** <id name="id" column="id"> ! <generator class="assigned"/> <!-- The Author must have the same identifier as the Person --> </id> --- 170,175 ---- <id name="id" column="id"> ! <!-- The Author must have the same identifier as the Person --> ! <generator class="assigned"/> </id> *************** *** 220,231 **** ) ! alter table authors add constraint authorsFK0 foreign key (id) references persons ! alter table author_work add constraint author_workFK0 foreign key (author_id) references authors ! alter table author_work add constraint author_workFK1 foreign key (work_id) references works]]></programlisting> </sect1> <sect1 id="examples-s2"> ! <title>Customer / Order / Product</title> <para> --- 229,243 ---- ) ! alter table authors ! add constraint authorsFK0 foreign key (id) references persons ! alter table author_work ! add constraint author_workFK0 foreign key (author_id) references authors ! alter table author_work ! add constraint author_workFK1 foreign key (work_id) references works]]></programlisting> </sect1> <sect1 id="examples-s2"> ! <title>Customer/Order/Product</title> <para> *************** *** 241,246 **** <mediaobject> ! <imageobject> ! <imagedata fileref="../images/CustomerOrderProduct.gif" format="GIF" align="center"/> </imageobject> </mediaobject> --- 253,261 ---- <mediaobject> ! <imageobject role="fo"> ! <imagedata fileref="images/AuthorWork.gif" format="GIF" align="center"/> ! </imageobject> ! <imageobject role="html"> ! <imagedata fileref="../images/AuthorWork.gif" format="GIF" align="center"/> </imageobject> </mediaobject> *************** *** 322,328 **** ) ! alter table orders add constraint ordersFK0 foreign key (customer_id) references customers ! alter table line_items add constraint line_itemsFK0 foreign key (product_id) references products ! alter table line_items add constraint line_itemsFK1 foreign key (order_id) references orders]]></programlisting> </sect1> --- 337,346 ---- ) ! alter table orders ! add constraint ordersFK0 foreign key (customer_id) references customers ! alter table line_items ! add constraint line_itemsFK0 foreign key (product_id) references products ! alter table line_items ! add constraint line_itemsFK1 foreign key (order_id) references orders]]></programlisting> </sect1> Index: index.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/index.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** index.xml 28 Jan 2003 13:25:11 -0000 1.2 --- index.xml 23 Feb 2003 13:53:24 -0000 1.3 *************** *** 1,3 **** ! <?xml version='1.0'?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd" --- 1,3 ---- ! <?xml version='1.0' encoding="iso-8859-1"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd" *************** *** 13,33 **** <!ENTITY examples SYSTEM "examples.xml"> <!ENTITY best-practices SYSTEM "best_practices.xml"> - ]> <book> <bookinfo> ! <title>Hibernate Reference Documentation</title> ! <subtitle>Relational Persistence for Idiomatic Java</subtitle> ! <subtitle>http://hibernate.sourceforge.net/</subtitle> ! <subtitle>Version: 2.0 beta1</subtitle> ! <date>28.01.2003</date> </bookinfo> ! &architecture; ! &session_config; ! &persistent-classes; --- 13,33 ---- <!ENTITY examples SYSTEM "examples.xml"> <!ENTITY best-practices SYSTEM "best_practices.xml"> ]> + <book> <bookinfo> ! <title>HIBERNATE - Relational Persistence for Idiomatic Java</title> ! <subtitle>Reference Documentation</subtitle> ! <releaseinfo>2.0 beta2</releaseinfo> </bookinfo> ! ! <toc/> ! &architecture; ! &session_config; ! &persistent-classes; *************** *** 37,49 **** &manipulating-data; ! &query-language; &transactions; ! &examples; &best-practices; - </book> --- 37,48 ---- &manipulating-data; ! &query-language; &transactions; ! &examples; &best-practices; </book> Index: manipulating_data.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/manipulating_data.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** manipulating_data.xml 16 Jan 2003 20:55:25 -0000 1.2 --- manipulating_data.xml 23 Feb 2003 13:53:24 -0000 1.3 *************** *** 141,147 **** </para> ! <programlisting><![CDATA[Iterator iter = sess.iterate("from q in class eg.Qux order by q.likeliness"); //fetch ids while ( iter.hasNext() ) { ! Qux qux = (Qux) iter.next(); //fetch the object // something we couldnt express in the query if ( qux.calculateComplicatedAlgorithm() ) { --- 141,148 ---- </para> ! <programlisting><![CDATA[// fetch ids ! Iterator iter = sess.iterate("from q in class eg.Qux order by q.likeliness"); while ( iter.hasNext() ) { ! Qux qux = (Qux) iter.next(); // fetch the object // something we couldnt express in the query if ( qux.calculateComplicatedAlgorithm() ) { *************** *** 169,175 **** </para> ! <programlisting><![CDATA[Iterator iter = sess.iterate( ! "select customer, product from customer in class Customer, product in class Product, " + ! "purchase in customer.purchases where product = purchase.product" );]]></programlisting> --- 170,179 ---- </para> ! <programlisting><![CDATA[ ! Iterator iter = sess.iterate( ! "select customer, product from customer in class Customer, " + ! "product in class Product, " + ! "purchase in customer.purchases " + ! "where product = purchase.product" );]]></programlisting> *************** *** 205,210 **** <programlisting><![CDATA[Iterator results = sess.iterate( ! "select cat.color, min(cat.birthdate), count(cat) from cat in class eg.Cat" + ! "group by cat.color" ); while ( results.hasNext() ) { --- 209,214 ---- <programlisting><![CDATA[Iterator results = sess.iterate( ! "select cat.color, min(cat.birthdate), count(cat) from cat in class eg.Cat " + ! "group by cat.color" ); while ( results.hasNext() ) { *************** *** 267,271 **** </para> ! <itemizedlist> <listitem> <para> --- 271,275 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 297,312 **** <sect2 id="manipulating-data-s5b"> ! <title>Scrollable iteration</title> ! <para> ! If your JDBC driver supports scrollable <literal>ResultSet</literal>s, the <literal>Query</literal> ! interface may be used to obtain a <literal>ScrollableResults</literal> which allows more flexible ! navigation of the query results. ! </para> ! <programlisting><![CDATA[Query q = sess.createQuery("select cat.name, cat from cat in class eg.DomesticCat order by cat.name"); ScrollableResults cats = q.scroll(); if ( cats.first() ) { ! //find the first name on each page of an alphabetical list of cats by name firstNamesOfPages = new ArrayList(); do { --- 301,317 ---- <sect2 id="manipulating-data-s5b"> ! <title>Scrollable iteration</title> ! <para> ! If your JDBC driver supports scrollable <literal>ResultSet</literal>s, the <literal>Query</literal> ! interface may be used to obtain a <literal>ScrollableResults</literal> which allows more flexible ! navigation of the query results. ! </para> ! <programlisting><![CDATA[Query q = sess.createQuery("select cat.name, cat from cat in class eg.DomesticCat " + ! "order by cat.name"); ScrollableResults cats = q.scroll(); if ( cats.first() ) { ! // find the first name on each page of an alphabetical list of cats by name firstNamesOfPages = new ArrayList(); do { *************** *** 316,320 **** while ( cats.scroll(PAGE_SIZE) ); ! //Now get the first page of cats pageOfCats = new ArrayList(); cats.beforeFirst(); --- 321,325 ---- while ( cats.scroll(PAGE_SIZE) ); ! // Now get the first page of cats pageOfCats = new ArrayList(); cats.beforeFirst(); *************** *** 334,342 **** <sect2 id="manipulating-data-s6"> <title>Filtering collections</title> ! <para> ! A collection <emphasis>filter</emphasis> is a special type of query that may be applied to ! a persistent collection (but not an array). The query string may refer to <literal>this</literal>, ! meaning the current collection element. ! </para> <programlisting><![CDATA[Collection blackKittens = session.filter( --- 339,347 ---- <sect2 id="manipulating-data-s6"> <title>Filtering collections</title> ! <para> ! A collection <emphasis>filter</emphasis> is a special type of query that may be applied to ! a persistent collection (but not an array). The query string may refer to <literal>this</literal>, ! meaning the current collection element. ! </para> <programlisting><![CDATA[Collection blackKittens = session.filter( *************** *** 344,355 **** )]]></programlisting> ! <para> ! The returned collection is considered a bag. ! </para> ! <para> ! Observe that filters do not require a <literal>from</literal> clause (though they may have ! one if required). Filters are not limited to returning the collection elements themselves. ! </para> <programlisting><![CDATA[Collection blackKittenMates = session.filter( --- 349,360 ---- )]]></programlisting> ! <para> ! The returned collection is considered a bag. ! </para> ! <para> ! Observe that filters do not require a <literal>from</literal> clause (though they may have ! one if required). Filters are not limited to returning the collection elements themselves. ! </para> <programlisting><![CDATA[Collection blackKittenMates = session.filter( *************** *** 376,380 **** <programlisting><![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) ); cat.setName("PK"); ! sess.flush(); //changes to cat are automatically detected and persisted]]></programlisting> <para> --- 381,385 ---- <programlisting><![CDATA[DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) ); cat.setName("PK"); ! sess.flush(); // changes to cat are automatically detected and persisted]]></programlisting> <para> *************** *** 408,412 **** // later, in a new session ! secondSession.update(cat, catID); // update cat secondSession.update(mate, mateID); // update mate]]></programlisting> --- 413,417 ---- // later, in a new session ! secondSession.update(cat, catID); // update cat secondSession.update(mate, mateID); // update mate]]></programlisting> *************** *** 446,470 **** </para> ! <itemizedlist> ! <listitem> ! <para> ! <literal>any</literal> - always save (this is the default!) ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>none</literal> - always update ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>null</literal> - save when identifier is null ! </para> ! </listitem> ! <listitem> ! <para> ! valid identifier value - save when identifier is null or the given value ! </para> ! </listitem> </itemizedlist> --- 451,475 ---- </para> ! <itemizedlist spacing="compact"> ! <listitem> ! <para> ! <literal>any</literal> - always save (this is the default!) ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>none</literal> - always update ! </para> ! </listitem> ! <listitem> ! <para> ! <literal>null</literal> - save when identifier is null ! </para> ! </listitem> ! <listitem> ! <para> ! valid identifier value - save when identifier is null or the given value ! </para> ! </listitem> </itemizedlist> *************** *** 477,482 **** // later, in a new session ! secondSession.saveOrUpdate(cat); // update existing state (cat has a non-null id) ! secondSession.saveOrUpdate(mate); // save the new instance (mate has a null id)]]></programlisting> </sect1> --- 482,487 ---- // later, in a new session ! secondSession.saveOrUpdate(cat); // update existing state (cat has a non-null id) ! secondSession.saveOrUpdate(mate); // save the new instance (mate has a null id)]]></programlisting> </sect1> *************** *** 514,518 **** </para> ! <itemizedlist> <listitem> <para> --- 519,523 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 533,537 **** </para> ! <itemizedlist> <listitem> <para> --- 538,542 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 551,555 **** </para> ! <itemizedlist> <listitem> <para> --- 556,560 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 582,586 **** </para> ! <itemizedlist> <listitem> <para> --- 587,591 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 644,648 **** </para> ! <itemizedlist> <listitem> <para> --- 649,653 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 666,670 **** </para> ! <orderedlist> <listitem> <para> --- 671,675 ---- </para> ! <orderedlist spacing="compact"> <listitem> <para> *************** *** 734,738 **** </para> ! <itemizedlist> <listitem> <para> --- 739,743 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 785,789 **** <programlisting><![CDATA[sess.flush(); ! sess.connection().commit(); //not necessary for JTA datasource]]></programlisting> <para> --- 790,794 ---- <programlisting><![CDATA[sess.flush(); ! sess.connection().commit(); // not necessary for JTA datasource]]></programlisting> <para> *************** *** 791,795 **** </para> ! <programlisting><![CDATA[tx.rollback(); // rollback the transaction]]></programlisting> <para> --- 796,800 ---- </para> ! <programlisting><![CDATA[tx.rollback(); // rollback the transaction]]></programlisting> <para> *************** *** 797,801 **** </para> ! <programlisting><![CDATA[//not necessary for JTA datasource, important otherwise sess.connection().rollback();]]></programlisting> --- 802,806 ---- </para> ! <programlisting><![CDATA[// not necessary for JTA datasource, important otherwise sess.connection().rollback();]]></programlisting> *************** *** 814,818 **** <programlisting><![CDATA[sess.flush(); ! sess.connection().commit(); //not necessary for JTA datasource sess.close();]]></programlisting> --- 819,823 ---- <programlisting><![CDATA[sess.flush(); ! sess.connection().commit(); // not necessary for JTA datasource sess.close();]]></programlisting> *************** *** 846,850 **** try { tx = sess.beginTransaction(); ! //do some work ... tx.commit(); --- 851,855 ---- try { tx = sess.beginTransaction(); ! // do some work ... tx.commit(); *************** *** 864,868 **** <programlisting><![CDATA[Session sess = factory.openSession(); try { ! //do some work ... sess.flush(); --- 869,873 ---- <programlisting><![CDATA[Session sess = factory.openSession(); try { ! // do some work ... sess.flush(); *************** *** 884,888 **** Session sess = factory.openSession(); try { ! //do some work ... sess.flush(); --- 889,893 ---- Session sess = factory.openSession(); try { ! // do some work ... sess.flush(); *************** *** 923,973 **** public class AuditInterceptor implements Interceptor, Serializable { - - private int updates; - private int creates; ! public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { ! } ! public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) { ! ! if ( entity instanceof Auditable ) { ! updates++; ! for ( int i=0; i<propertyNames.length; i++ ) { ! if ( "lastUpdateTimestamp".equals( propertyNames[i] ) ) { ! currentState[i] = new Date(); ! return true; ! } ! } ! } ! return false; ! } ! public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { ! return false; ! } ! public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { ! if ( entity instanceof Auditable ) { ! creates++; ! for ( int i=0; i<propertyNames.length; i++ ) { ! if ( "createTimestamp".equals( propertyNames[i] ) ) { ! state[i] = new Date(); ! return true; ! } ! } ! } ! return false; ! } ! public void postFlush(Iterator entities) { ! System.out.println("Creations: " + creates + ", Updates: " + updates); ! } ! public void preFlush(Iterator entities) { ! updates=0; ! creates=0; ! } }]]></programlisting> --- 928,996 ---- public class AuditInterceptor implements Interceptor, Serializable { ! private int updates; ! private int creates; ! public void onDelete(Object entity, ! Serializable id, ! Object[] state, ! String[] propertyNames, ! Type[] types) { ! // do nothing ! } ! public boolean onFlushDirty(Object entity, ! Serializable id, ! Object[] currentState, ! Object[] previousState, ! String[] propertyNames, ! Type[] types) { ! if ( entity instanceof Auditable ) { ! updates++; ! for ( int i=0; i < propertyNames.length; i++; ) { ! if ( "lastUpdateTimestamp".equals( propertyNames[i] ) ) { ! currentState[i] = new Date(); ! return true; ! } ! } ! } ! return false; ! } ! public boolean onLoad(Object entity, ! Serializable id, ! Object[] state, ! String[] propertyNames, ! Type[] types) { ! return false; ! } ! public boolean onSave(Object entity, ! Serializable id, ! Object[] state, ! String[] propertyNames, ! Type[] types) { ! ! if ( entity instanceof Auditable ) { ! creates++; ! for ( int i=0; i<propertyNames.length; i++ ) { ! if ( "createTimestamp".equals( propertyNames[i] ) ) { ! state[i] = new Date(); ! return true; ! } ! } ! } ! return false; ! } ! ! public void postFlush(Iterator entities) { ! System.out.println("Creations: " + creates + ", Updates: " + updates); ! } + public void preFlush(Iterator entities) { + updates=0; + creates=0; + } }]]></programlisting> Index: persistent_classes.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/persistent_classes.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** persistent_classes.xml 1 Jan 2003 13:46:32 -0000 1.1.1.1 --- persistent_classes.xml 23 Feb 2003 13:53:24 -0000 1.2 *************** *** 22,74 **** private char sex; private float weight; ! private void setId(long id) { ! this.id=id; } public long getId() { ! return id; } ! void setMate(Cat mate) { ! this.mate = mate; } public Cat getMate() { ! return mate; } ! void setBirthdate(Date date) { ! birthdate = date; } public Date getBirthdate() { ! return birthdate; } void setWeight(float weight) { ! this.weight = weight; } public float getWeight() { ! return weight; } public Color getColor() { ! return color; } void setColor(Color color) { ! this.color = color; } void setKittens(Set kittens) { ! this.kittens = kittens; } public Set getKittens() { ! return kittens; } // addKitten not needed by Hibernate public void addKitten(Cat kitten) { ! kittens.add(kitten); } void setSex(char sex) { ! this.sex=sex; } public char getSex() { ! return sex; } }]]></programlisting> --- 22,74 ---- private char sex; private float weight; ! private void setId(long id) { ! this.id=id; } public long getId() { ! return id; } ! void setMate(Cat mate) { ! this.mate = mate; } public Cat getMate() { ! return mate; } ! void setBirthdate(Date date) { ! birthdate = date; } public Date getBirthdate() { ! return birthdate; } void setWeight(float weight) { ! this.weight = weight; } public float getWeight() { ! return weight; } public Color getColor() { ! return color; } void setColor(Color color) { ! this.color = color; } void setKittens(Set kittens) { ! this.kittens = kittens; } public Set getKittens() { ! return kittens; } // addKitten not needed by Hibernate public void addKitten(Cat kitten) { ! kittens.add(kitten); } void setSex(char sex) { ! this.sex=sex; } public char getSex() { ! return sex; } }]]></programlisting> *************** *** 131,135 **** </para> ! <itemizedlist> <listitem> <para> --- 131,135 ---- </para> ! <itemizedlist spacing="compact"> <listitem> <para> *************** *** 182,189 **** <para> ! Optionally, a persistent class might implement the interface </para> ! <programlisting><![CDATA[public interface Lifecycle { public boolean onSave(Session s) throws CallbackException; public boolean onUpdate(Session s) throws CallbackException; --- 182,199 ---- <para> ! Optionally, a persistent class might implement the interface ! <literal>Lifecycle</literal> which provides some callbacks that allow ! the persistent object to perform necessary initialization/cleanup after ! save or load and before deletion or update. </para> ! <programlistingco> ! <areaspec> ! <area id="lifecycle1" coords="2 70"/> ! <area id="lifecycle2" coords="3 70" /> ! <area id="lifecycle3" coords="4 70"/> ! <area id="lifecycle4" c... [truncated message content] |