From: <one...@us...> - 2003-04-11 07:12:26
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv10161/reference/src Modified Files: advanced_or_mapping.xml basic_or_mapping.xml query_language.xml Log Message: documented <any> and fixed doco bugs Index: advanced_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/advanced_or_mapping.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** advanced_or_mapping.xml 6 Apr 2003 11:03:12 -0000 1.14 --- advanced_or_mapping.xml 11 Apr 2003 07:12:21 -0000 1.15 *************** *** 500,504 **** ! <sect2 id="adv-or-mapping-s1-11"> <title>Ternary Associations</title> <para> --- 500,504 ---- ! <sect2 id="adv-or-mapping-s1-11a"> <title>Ternary Associations</title> <para> *************** *** 521,524 **** --- 521,534 ---- </sect2> + + <sect2 id="adv-or-mapping-s1-11b"> + <title>Heterogeneous Associations</title> + <para> + The <literal><many-to-any></literal> and <literal><index-many-to-any></literal> + elements provide for true heterogeneous associations. These mapping elements work in the + same way as the <literal><any></literal> element - and should also be used + rarely, if ever. + </para> + </sect2> <sect2 id="adv-or-mapping-s1-12"> *************** *** 1029,1033 **** </sect2> ! <sect2 id="adv-or-mapping-s3-3"> <title>Nonstrict Read / Write Cache</title> --- 1039,1043 ---- </sect2> ! <sect2 id="adv-or-mapping-s3-4"> <title>Nonstrict Read / Write Cache</title> Index: basic_or_mapping.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/basic_or_mapping.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** basic_or_mapping.xml 6 Apr 2003 10:41:43 -0000 1.13 --- basic_or_mapping.xml 11 Apr 2003 07:12:21 -0000 1.14 *************** *** 744,748 **** <callout arearefs="property1"> <para> ! <literal>name</literal> the name of the property, with an initial lowercase letter. </para> --- 744,748 ---- <callout arearefs="property1"> <para> ! <literal>name</literal>: the name of the property, with an initial lowercase letter. </para> *************** *** 750,754 **** <callout arearefs="property2"> <para> ! <literal>column</literal> (optional - defaults to the property name) the name of the mapped database table column. </para> --- 750,754 ---- <callout arearefs="property2"> <para> ! <literal>column</literal> (optional - defaults to the property name): the name of the mapped database table column. </para> *************** *** 756,765 **** <callout arearefs="property3"> <para> ! <literal>type</literal> (optional) a name that indicates the Hibernate type. </para> </callout> <callout arearefs="property4-5"> <para> ! <literal>update, insert</literal> (optional - defaults to <literal>true</literal>) specifies that the mapped columns should be included in SQL <literal>UPDATE</literal> and/or <literal>INSERT</literal> statements. Setting both to <literal>false</literal> --- 756,765 ---- <callout arearefs="property3"> <para> ! <literal>type</literal> (optional): a name that indicates the Hibernate type. </para> </callout> <callout arearefs="property4-5"> <para> ! <literal>update, insert</literal> (optional - defaults to <literal>true</literal>) : specifies that the mapped columns should be included in SQL <literal>UPDATE</literal> and/or <literal>INSERT</literal> statements. Setting both to <literal>false</literal> *************** *** 1499,1503 **** There is one further type of property mapping. The <literal><any></literal> mapping element defines a polymorphic association to classes from multiple tables. This type of mapping always ! requires more than one column. The first column holds the class name of the associated entity. The remaining columns hold the identifier. It is impossible to specify a foreign key constraint for this kind of association, so this is most certainly not meant as the usual way of mapping --- 1499,1503 ---- There is one further type of property mapping. The <literal><any></literal> mapping element defines a polymorphic association to classes from multiple tables. This type of mapping always ! requires more than one column. The first column holds the type of the associated entity. The remaining columns hold the identifier. It is impossible to specify a foreign key constraint for this kind of association, so this is most certainly not meant as the usual way of mapping *************** *** 1506,1520 **** </para> ! <programlisting><![CDATA[<any name="anyEntity" id-type="long"> ! <column name="class_name"/> <column name="id"/> </any>]]></programlisting> <para> The old <literal>object</literal> type that filled a similar role in Hibernate 1.2 is still supported, but is now semi-deprecated. </para> ! </sect2> </sect1> --- 1506,1569 ---- </para> ! <programlisting><![CDATA[<any name="anyEntity" id-type="long" meta-type="eg.custom.Class2TablenameType"> ! <column name="table_name"/> <column name="id"/> </any>]]></programlisting> <para> + The <literal>meta-type</literal> attribute lets the application specify a custom type that maps + database column values to persistent classes which have identifier properties of the type + specified by <literal>id-type</literal>. + </para> + + <programlistingco> + <areaspec> + <area id="any1" coords="2 42"/> + <area id="any2" coords="3 42"/> + <area id="any3" coords="4 42"/> + <area id="any4" coords="5 42"/> + </areaspec> + <programlisting><![CDATA[<any + name="propertyName" + id-type="idtypename" + meta-type="metatypename" + cascade="none|all|save-update" + > + <column .... /> + <column .... /> + ..... + </any>]]></programlisting> + <calloutlist> + <callout arearefs="any1"> + <para> + <literal>name</literal>: the property name. + </para> + </callout> + <callout arearefs="any2"> + <para> + <literal>id-type</literal>: the identifier type. + </para> + </callout> + <callout arearefs="any3"> + <para> + <literal>meta-type</literal> (optional - defaults to <literal>class</literal>): + a type that maps <literal>java.lang.Class</literal> to a single database column. + </para> + </callout> + <callout arearefs="any4"> + <para> + <literal>cascade</literal> (optional- defaults to <literal>none</literal>): + the cascade style. + </para> + </callout> + </calloutlist> + </programlistingco> + + <para> The old <literal>object</literal> type that filled a similar role in Hibernate 1.2 is still supported, but is now semi-deprecated. </para> ! </sect2> </sect1> Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** query_language.xml 31 Mar 2003 06:35:28 -0000 1.9 --- query_language.xml 11 Apr 2003 07:12:21 -0000 1.10 *************** *** 325,333 **** <programlisting><![CDATA[from eg.Cat cat where cat.class = eg.DomesticCat]]></programlisting> ! <para> ! You may also specify properties of components (and of components of components). ! Never try to use a path-expression that ends in a property of component type ! (as opposed to a property of a component). For example, if <literal>store.owner</literal> is an entity with a component <literal>address</literal> </para> --- 325,333 ---- <programlisting><![CDATA[from eg.Cat cat where cat.class = eg.DomesticCat]]></programlisting> ! <para> ! You may also specify properties of components or composite user types (and of components ! of components, etc). Never try to use a path-expression that ends in a property of component ! type (as opposed to a property of a component). For example, if <literal>store.owner</literal> is an entity with a component <literal>address</literal> </para> *************** *** 336,339 **** --- 336,353 ---- store.owner.address //error!]]></programlisting> + <para> + An "any" type has the special properties <literal>id</literal> and <literal>class</literal>, + allowing us to express a join in the following way (where <literal>AuditLog.item</literal> + is a property mapped with <literal><any></literal>). + </para> + + <programlisting><![CDATA[from eg.AuditLog log, eg.Payment payment + where log.item.class = 'eg.Payment' and log.item.id = payment.id]]></programlisting> + + <para> + Notice that <literal>log.item.class</literal> and <literal>payment.class</literal> + would refer to the values of completely different database columns in the above query. + </para> + </sect1> |