brj         2005/01/15 05:08:36

  Modified:    src/doc/forrest/src/documentation/content/xdocs/docu/guides
                        basic-technique.xml
  Log:
  added description of non-pk-based relationships
  
  Revision  Changes    Path
  1.3       +146 -16   
db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml
  
  Index: basic-technique.xml
  ===================================================================
  RCS file: 
/home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/guides/basic-technique.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- basic-technique.xml       30 Jun 2004 15:36:50 -0000      1.2
  +++ basic-technique.xml       15 Jan 2005 13:08:36 -0000      1.3
  @@ -22,7 +22,7 @@
           <title>Basic Technique</title>
           <authors>
               <person name="Thomas Mahler" email="[EMAIL PROTECTED]"/>
  -            <person name="Jakob Braeuchli" email="[EMAIL PROTECTED]"/>
  +            <person name="Jakob Braeuchi" email="[EMAIL PROTECTED]"/>
               <person name="Armin Waibel" email="[EMAIL PROTECTED]"/>
           </authors>
       </header>
  @@ -100,18 +100,24 @@
                       These elements define foreign key attributes.
                       The element
                   <source><![CDATA[
  -                <foreignkey field-ref="productGroupId"/>]]></source>
  -                    contains the name of the field-descriptor describing the
  -                    foreignkey fields.
  +<foreignkey field-ref="productGroupId"/>]]></source>
  +                    contains the name of the field-descriptor describing the 
foreignkey fields.
                       The FieldDescriptor with the name "productGroupId" 
describes the foreignkey attribute
                       productGroupId:
                       <source><![CDATA[
  -                <field-descriptor
  -                    name="productGroupId"
  -                    column="Kategorie_Nr"
  -                    jdbc-type="INTEGER"
  -                />]]></source>
  -                </li>
  +<field-descriptor
  +    name="productGroupId"
  +    column="Kategorie_Nr"
  +    jdbc-type="INTEGER"
  +/>]]></source>
  +                                     OJB assumes that field used in 
field-ref references the <em>primary-key</em> field
  +                                     of the referenced type 
"org.apache.ojb.broker.ProductGroup".
  +                    If field-ref should point to another field use the 
<em>target-field-ref</em>: 
  +                <source><![CDATA[
  +<foreignkey field-ref="productGroupName" 
target-field-ref="groupName"/>]]></source>
  +                An example of a 1:1 relationship using a non-primary-key 
field can be 
  +                found <link href="#non-pk-1:1">here</link>.
  +               </li>
               </ul>
               <p>
                   See the following extract from the repository.xml file 
containing
  @@ -205,11 +211,66 @@
   >
       <foreignkey field-ref="sampleArticleId""/>
   </reference-descriptor>]]></source>
  +
               <note>
                   When using primitive primary key fields, please pay 
attention on
                   <link href="site:faq/primitive-null">how OJB manage 
<code>null</code> for primitive PK/FK</link>
               </note>
   
  +        <anchor id="non-pk-1:1"/>
  +        <section>
  +            <title>1:1 using non-primary-key field</title>
  +                     <p>
  +                     This example shows a relationship based on the field 
"productGroupName" referencing a non-primary-key-field. 
  +                     This field of the class 
"org.apache.ojb.broker.NoPkReferenceTest$Article_2"     is pointing to the 
  +                     field "groupName" of the referenced class.
  +                     </p>
  +            <source><![CDATA[
  +<class-descriptor
  +     class="org.apache.ojb.broker.NoPkReferenceTest$Article_2"
  +     table="Artikel_2" >
  +  <field-descriptor
  +     name="articleId"
  +     column="Artikel_Nr"
  +     jdbc-type="INTEGER"
  +     primarykey="true"
  +     autoincrement="true"
  +  />
  +  ...
  +  <field-descriptor
  +     name="productGroupName"
  +     column="KatName"
  +     jdbc-type="VARCHAR"
  +  />
  +  ...
  +  <reference-descriptor
  +        name="productGroup"
  +        class-ref="org.apache.ojb.broker.NoPkReferenceTest$ProductGroup_2"
  +  >
  +     <foreignkey field-ref="productGroupName" target-field-ref="groupName"/>
  +  </reference-descriptor>
  +</class-descriptor>
  +
  +<class-descriptor
  +     class="org.apache.ojb.broker.NoPkReferenceTest$ProductGroup_2"
  +     table="Kategorien_2" >
  +  <field-descriptor
  +     name="groupId"
  +     column="Kategorie_Nr"
  +     jdbc-type="INTEGER"
  +     primarykey="true"
  +     autoincrement="true"
  +  />
  +  <field-descriptor
  +     name="groupName"
  +     column="Kategorie_Name"
  +     jdbc-type="VARCHAR"
  +  />
  +  ...
  +</class-descriptor>]]></source>
  +
  +     </section>                      
  +
               <section>
                   <title>1:1 auto-xxx setting</title>
                   <p>
  @@ -334,7 +395,7 @@
               <p>
                   To declare the foreign key mechanics of this collection 
attribute
                   we must add a CollectionDescriptor to the ClassDescriptor of 
the
  -                ProductGoup class. This descriptor contains the following
  +                ProductGroup class. This descriptor contains the following
                   information:
               </p>
               <ol>
  @@ -350,10 +411,18 @@
                   <li>
                       The name of field-descriptor of the element class
                       used as foreign key attributes are defined in 
inverse-foreignkey elements:
  -                    <source><![CDATA[
  +                <source><![CDATA[
   <inverse-foreignkey field-ref="productGroupId"/>]]></source>
                       This is again pointing to the field-descriptor for the 
attribute
                       <code>productGoupId</code> in class Article.
  +                    
  +                                     OJB assumes that field used in 
field-ref references the <em>primary-key</em> field
  +                                     of the referenced type 
"org.apache.ojb.broker.Article".
  +                    If field-ref should point to another field use the 
<em>target-field-ref</em>: 
  +                <source><![CDATA[
  +<inverse-foreignkey field-ref="productGroupName" 
target-field-ref="groupName"/>]]></source>
  +                An example of a 1:n relationship using a non-primary-key 
field can be 
  +                found <link href="#non-pk-1:n">here</link>.
                   </li>
                   <li>
                       optional attributes to define the sort order of the 
retrieved collection:
  @@ -364,7 +433,7 @@
                   the ProductGoup ClassDescriptor:</p>
               <source><![CDATA[
   <!-- Definitions for org.apache.ojb.broker.ProductGroup -->
  - <class-descriptor
  +<class-descriptor
       class="org.apache.ojb.broker.ProductGroup"
       table="Kategorien"
    >
  @@ -393,7 +462,8 @@
       >
          <inverse-foreignkey field-ref="productGroupId"/>
       </collection-descriptor>
  - </class-descriptor>]]></source>
  +</class-descriptor>]]></source>
  +
               <p>
                   With the mapping shown above OJB has two possibilities to 
load the Articles belonging
                   to a ProductGroup:
  @@ -447,6 +517,66 @@
                   <link href="site:faq/primitive-null">how OJB manage 
<code>null</code> for primitive PK/FK</link>
               </note>
   
  +        <anchor id="non-pk-1:n"/>
  +        <section>
  +            <title>1:n using non-primary-key field</title>
  +                     <p>
  +                     This example shows a relationship based on the field 
"productGroupName" referencing a non-primary-key-field. 
  +                     This field of the class 
"org.apache.ojb.broker.NoPkReferenceTest$Article_2"     is pointing to the 
  +                     field "groupName" of the referenced class.
  +                     </p>
  + <source><![CDATA[
  +<class-descriptor
  +     class="org.apache.ojb.broker.NoPkReferenceTest$Article_2"
  +     table="Artikel_2" >
  +  <field-descriptor
  +     name="articleId"
  +     column="Artikel_Nr"
  +     jdbc-type="INTEGER"
  +     primarykey="true"
  +     autoincrement="true"
  +  />
  +  ...
  +  <field-descriptor
  +     name="productGroupName"
  +     column="KatName"
  +     jdbc-type="VARCHAR"
  +  />
  +  ...
  +</class-descriptor>
  +
  +<class-descriptor
  +     class="org.apache.ojb.broker.NoPkReferenceTest$ProductGroup_2"
  +     table="Kategorien_2" >
  +  <field-descriptor
  +     name="groupId"
  +     column="Kategorie_Nr"
  +     jdbc-type="INTEGER"
  +     primarykey="true"
  +     autoincrement="true"
  +  />
  +  <field-descriptor
  +     name="groupName"
  +     column="Kategorie_Name"
  +     jdbc-type="VARCHAR"
  +  />
  +  <field-descriptor
  +     name="description"
  +     column="Beschreibung"
  +     jdbc-type="VARCHAR"
  +  />
  +  <collection-descriptor
  +     name="allArticlesInGroup"
  +     element-class-ref="org.apache.ojb.broker.NoPkReferenceTest$Article_2"
  +     auto-retrieve="true"
  +     auto-update="true"
  +     auto-delete="false"
  +  >
  +     <inverse-foreignkey field-ref="productGroupName" 
target-field-ref="groupName"/>
  +  </collection-descriptor>
  +</class-descriptor>]]></source>
  +        </section>
  +
               <section>
                   <title>1:n auto-xxx setting</title>
                   <p>
  @@ -867,7 +997,7 @@
                   <link href="site:faq/primitive-null">how OJB manage 
<code>null</code> for primitive PK/FK</link>
               </note>
   
  -            
  +
               <section>
                   <title>m:n auto-xxx setting</title>
                   <p>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to