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 2005/12/20 01:35:42 UTC

cvs commit: db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/howtos howto-use-anonymous-keys.xml

arminw      2005/12/19 16:35:42

  Modified:    src/doc/forrest/src/documentation/content/xdocs/docu/howtos
                        Tag: OJB_1_0_RELEASE howto-use-anonymous-keys.xml
  Log:
  add new links, code sample cleanup
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.2   +37 -85    db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/howtos/howto-use-anonymous-keys.xml
  
  Index: howto-use-anonymous-keys.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/doc/forrest/src/documentation/content/xdocs/docu/howtos/howto-use-anonymous-keys.xml,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- howto-use-anonymous-keys.xml	14 Dec 2005 01:19:21 -0000	1.1.2.1
  +++ howto-use-anonymous-keys.xml	20 Dec 2005 00:35:41 -0000	1.1.2.2
  @@ -54,10 +54,10 @@
               </p>
               <source><![CDATA[
   {
  -Foo child = new SomeOtherFooType();
  -Foo parent = new SomeFooType();
  -child.setParent(parent);
  -child.setParentId(parent.getId());
  +    Foo child = new SomeOtherFooType();
  +    Foo parent = new SomeFooType();
  +    child.setParent(parent);
  +    child.setParentId(parent.getId());
   }]]></source>
               <p>
                   This is double the work required - you set up the object relationship, then set up the key
  @@ -66,9 +66,9 @@
               </p>
   <source><![CDATA[
   {
  -Foo child = new Foo();
  -Foo parent = new Foo();
  -child.setParent(parent);
  +    Foo child = new Foo();
  +    Foo parent = new Foo();
  +    child.setParent(parent);
   }]]></source>
               <p>
                   OJB can provide transparent key relationship maintenance behind the scenes for
  @@ -138,103 +138,52 @@
                   <source><![CDATA[
   public class Desk
   {
  +    private Integer id;
       private Finish finish;
       /** Contains Drawer instances */
       private List drawers;
       private int numberOfLegs;
  -    private Integer id;
   
       public Desk()
       {
           this.drawers = new ArrayList();
       }
  -
  -    public List getDrawers()
  -    {
  -        return this.drawers;
  -    }
  -
  -    public int getNumberOfLegs()
  -    {
  -        return this.numberOfLegs;
  -    }
  -
  -    public void setNumberOfLegs(int num)
  -    {
  -        this.numberOfLegs = num;
  -    }
  -
  -    public Finish getFinish()
  -    {
  -        return this.finish;
  -    }
  -
  -    public void setFinish(Finish finish)
  -    {
  -        this.finish = finish;
  -    }
  +....
  +// getter/setter
   }
   
  -
   public class Drawer
   {
  +    private Integer id;
       /** Contains Thing instances */
       private List stuffInDrawer;
  -    private Integer id;
  -
  -    public List getStuffInDrawer()
  -    {
  -        return this.stuffInDrawer;
  -    }
   
       public Drawer()
       {
           this.stuffInDrawer = new ArrayList();
       }
  -}
   
  +....
  +// getter/setter
  +}
   
   public class Finish
   {
  +    private Integer id;
       private String wood;
       private String color;
  -    private Integer id;
   
  -    public String getWood()
  -    {
  -        return this.wood;
  -    }
  -
  -    public void setWood(String wood)
  -    {
  -        this.wood = wood;
  -    }
  -
  -    public String getColor()
  -    {
  -        return this.color;
  -    }
  -
  -    public void setColor(String color)
  -    {
  -        this.color = color;
  -    }
  +....
  +// getter/setter
   }
   
   public class Thing
   {
  -    private String name;
       private Integer id;
  +    private String name;
   
  -    public String getName()
  -    {
  -        return this.name;
  -    }
  -
  -    public void setName(String name)
  -    {
  -        this.name = name;
  -    }
  +....
  +// getter/setter
   }]]></source>
                   <p>
                       A Desk will typically reference multiple drawers and one finish.
  @@ -294,12 +243,13 @@
                       keys allow us to do that.
                   </p>
                   <p>
  -                    The repository.xml must know about the database columns used for referential integrity, but
  -                    OJB can maintain the foreign key relationships behind the scenes - freeing the developer
  +                    The <a href="site:repository/introduction">repository.xml</a> must know about the
  +                    database columns used for referential integrity, but OJB can maintain the foreign key
  +                    relationships behind the scenes - freeing the developer
                       to focus on more accurate modeling of her objects to the problem, instead of the the
  -                    persistance mechanism. Doing this is also very simple - in the repository.xml file mark
  -                    the field descriptors with a
  -                    <code>access="anonymous"</code> attribute.
  +                    persistance mechanism. Doing this is also very simple - in the <em>repository.xml</em>
  +                    file mark the <a href="site:repository/field-descriptor">field descriptors</a>
  +                    with a <code>access="anonymous"</code> attribute.
                   </p>
                   <source><![CDATA[
   <class-descriptor
  @@ -324,18 +274,18 @@
           jdbc-type="INTEGER"
           access="anonymous" />
   
  +    <reference-descriptor
  +        name="finish"
  +        class-ref="Finish">
  +            <foreignkey field-ref="finishId"/>
  +    </reference-descriptor>
  +
       <collection-descriptor
           name="drawers"
           element-class-ref="Drawer"
           >
           <inverse-foreignkey field-ref="deskId"/>
       </collection-descriptor>
  -
  -    <reference-descriptor
  -        name="finish"
  -        class-ref="Finish">
  -            <foreignkey field-ref="finishId"/>
  -    </reference-descriptor>
   </class-descriptor>
   
   <class-descriptor
  @@ -413,7 +363,8 @@
           />
   </class-descriptor>]]></source>
                   <p>
  -                    Look first at the class descriptor for the Thing class. Notice the field-descriptor with
  +                    Look first at the class descriptor for the Thing class. Notice the
  +                    <a href="site:repository/field-descriptor">field-descriptor</a> with
                       the name attribute "drawerId". This field is labeled as anonymous access. Because it is
                       anonymous access OJB will not attempt to assign the value here to a "drawerId" field or
                       property on the Thing class. Normally the name attribute is used as the Java name for the
  @@ -430,7 +381,8 @@
                   </p>
                   <p>
                       The same type mapping that is used for the collection descriptor in the Drawer descriptor
  -                    is also used for the 1:1 reference descriptor in the Desk descriptor.
  +                    is also used for the 1:1
  +                    <a href="site:repository/reference-descriptor">reference descriptor</a> in the Desk descriptor.
                   </p>
                   <p>
                       The primary keys are populated into the objects as it is generally a good practice to not
  
  
  

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