You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2006/02/07 22:58:53 UTC

svn commit: r375734 - /db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml

Author: arminw
Date: Tue Feb  7 13:58:51 2006
New Revision: 375734

URL: http://svn.apache.org/viewcvs?rev=375734&view=rev
Log:
adapt docs to explain 'new' table-per-subclass inheritance

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml?rev=375734&r1=375733&r2=375734&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/doc/forrest/src/documentation/content/xdocs/docu/guides/advanced-technique.xml Tue Feb  7 13:58:51 2006
@@ -681,8 +681,21 @@
                     <a href="#classes-inheritance-example">table-per-class mapping</a>.
                 </p>
                 <p>
-                    The next code block contains the <a href="site:repository/class-descriptor">class-descriptors</a> of our
-                    <a href="#mapping-inheritance-example">mapping example</a>.
+                    To define the reference to the super-class OJB use an ordinary
+                    <a href="site:repository/reference-descriptor">1:1 reference</a> with the
+                    specific keyword <em>super</em> as field name.
+                </p>
+                <source><![CDATA[
+<reference-descriptor name="super" class-ref="referenced.super.class"/>
+                ]]></source>
+                <p>
+                    The <code>name="super"</code> attribute is not used to address an actual
+                    attribute of the super-class but as a marker keyword defining the <em>JOIN</em>
+                    to the super-class.
+                </p>
+                <p>
+                    The next code block contains the <a href="site:repository/class-descriptor">class-descriptors</a>
+                    of our <a href="#mapping-inheritance-example">mapping example</a>.
                 </p>
                 <source><![CDATA[
 <class-descriptor
@@ -722,7 +735,8 @@
     <reference-descriptor name="super"
         class-ref="Employee"
     >
-        <foreignkey field-ref="id"/>
+        <!-- it's possible to define the FK but normally not needed -->
+        <!--<foreignkey field-ref="id"/>-->
     </reference-descriptor>
 </class-descriptor>
 
@@ -742,11 +756,8 @@
         jdbc-type="INTEGER"
     />
 
-    <reference-descriptor name="super"
-        class-ref="Executive"
-    >
-        <foreignkey field-ref="id"/>
-    </reference-descriptor>
+    <reference-descriptor name="super" class-ref="Executive"/>
+
 </class-descriptor>]]></source>
                 <p>
                     The mapping for base class <code>Employee</code> is ordinary and we using
@@ -757,15 +768,11 @@
                     primary keys of the base class to all subclasses.
                 </p>
                 <p>
-                    As you can see this mapping needs a special
+                    As you can see this mapping defines the specific
                     <a href="site:repository/reference-descriptor">reference-descriptor</a>
                     in the subclasses <code>Executive</code> and <code>Manager</code> that advises OJB to load
                     the values for the inherited attributes from the super-class by a <em>JOIN</em> using the
                     foreign key reference.
-               <br/>
-                    The <code>name="super"</code> attribute is not used to address an actual
-                    attribute of the super-class but as a marker keyword defining the <em>JOIN</em>
-                    to the super-class.
                 </p>
                 <note>
                     1. The <a href="site:basic-technique/cascading"><em>auto-xxx</em> attributes</a> and the
@@ -819,9 +826,8 @@
                 <p>
                     The above example is based on the assumption that the
                     <a href="site:repository/primary-key">primary key</a> attribute
-                    <code>Employee.id</code> and its underlying column
-                    <code>EMPLOYEE.ID</code> is also used as the foreign key attribute in the
-                    the subclasses.
+                    of the sub-class <code>id</code> and its underlying column is also
+                    used as the foreign key attribute in the the subclasses.
                 </p>
                 <p>
                     Now let us consider a case where this is not possible, then it's possible
@@ -831,15 +837,17 @@
                 <p>
                     In this case the layout for class <code>Executive</code> would need an
                     additional field <code>employeeFk</code> to store the foreign key reference
-                    to <code>Employee</code>.
+                    to <code>Employee</code>. Then the mapping is similar to a
+                    <a href="site:basic-technique/one-to-one">1:1 reference</a>.
                     <br/>
-                    To avoid the additional field in the subclass (if desired) we can use OJB's
+                    To avoid the additional field in the subclass we can use OJB's
                     <a href="site:advanced-technique/anonymous-keys">anonymous field feature</a>
-                    to get everything working without the <code>employeeFk</code> attribute in subclass
-                    <code>Employee</code> (thus the <a href="#classes-inheritance-example">java classes</a> of our
-                    <a href="#mapping-inheritance-example">mapping example</a>). We keep the
-                    <a href="site:repository/field-descriptor">field-descriptor</a> for <code>employeeFk</code>,
-                    but declare it as an <em>anonymous field</em>.
+                    to get everything working without modification of the the
+                    <a href="#mapping-inheritance-example">mapping example</a> classes.
+                    <br/>
+                    We keep the
+                    <a href="site:repository/field-descriptor">field-descriptor</a> for the
+                    additional FK field <code>employeeFk</code>, but declare it as an <em>anonymous field</em>.
                     We just have to add an attribute
                     <code>access="anonymous"</code> to the new field-descriptor <code>employeeFk</code>:.
                 </p>
@@ -878,6 +886,8 @@
         column="DEPARTMENT"
         jdbc-type="VARCHAR"
     />
+
+    <!-- the additional anonymous FK column -->
     <field-descriptor
         name="employeeFk"
         column="EMPLOYEE_FK"
@@ -908,6 +918,7 @@
         jdbc-type="INTEGER"
     />
 
+    <!-- the additional anonymous FK column -->
     <field-descriptor
         name="executiveFk"
         column="EXECUTIVE_FK"
@@ -922,8 +933,9 @@
     </reference-descriptor>
 </class-descriptor>]]></source>
                 <p>
-                    Now it's possible to use <em>autoincrement</em> primary key fields in all classes
-                    of the hierarchy (because they are decoupled from the inheritance references).
+                    Now it's mandatory to use <em>autoincrement</em> primary key fields in all classes
+                    of the hierarchy (because they are decoupled from the inheritance references and on insert
+                    OJB have to assign the PK values of the sub-class tables).
                     <br/>
                     The <em>foreignkey</em>-element have to refer the new (anomymous)
                     foreign-key field.
@@ -938,7 +950,8 @@
                         <a href="site:sequence-manager/identity-columns">database idenity columns</a> based
                         <a href="site:sequence-manager">sequence-manager</a>. In this case it's mandatory to use
                         a different value scope (start index of identity column) for each class in hierarchy
-                        (e.g. 1 for Employee, 1000000000 for Executive, ...).
+                        (e.g. 1 for Employee, 1000000000 for Executive, ...) or the much easier mapping
+                        described <a href="#table-per-subclass">above</a>.
                     </warning>
                     </section>
             </section>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org