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 "Spräner, Carsten" <Ca...@viadee.de> on 2003/05/28 14:41:10 UTC

One Class One Table

In a posting i read a comment from thma that the new feature of annonymous access gives the posibility to support the inharitance strategy "One Class One Table". Can anyone describe how this works in detail??

Thanx

carsten


Re: [PATCH] xdocs/howto-use-anonymous-keys.xml

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Brain,

damned 'attachment-eater' ;-)
please send me your patch directly.

regards,
Armin

----- Original Message -----
From: "Brian McCallister" <mc...@forthillcompany.com>
To: "OJB Developers List" <oj...@db.apache.org>
Sent: Thursday, May 29, 2003 5:49 PM
Subject: Re: [PATCH] xdocs/howto-use-anonymous-keys.xml


> Bizarre, the attchements didn't make it through.
>
> One more try, and the patch inline at the end.
>
>


------------------------------------------------------------------------
--------


>
>
> -Brian
>
>
>
> On Thursday, May 29, 2003, at 10:24 AM, Brian McCallister wrote:
>
> > I messed up the howto-use-anonymous-keys.xml howto, sorry about
that.
> > Didn't c&p final code in to the one I submitted.
> >
> > Here is a (fully tested and working) patch for the howto, as well as
> > the patched file (don't know which form is preferred).
> >
> > -Brian
> >
> >
> >
>
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
> Index: xdocs/howto-use-anonymous-keys.xml
> ===================================================================
> RCS file: /home/cvspublic/db-ojb/xdocs/howto-use-anonymous-keys.xml,v
> retrieving revision 1.1
> diff -c -r1.1 howto-use-anonymous-keys.xml
> *** xdocs/howto-use-anonymous-keys.xml 15 May 2003 06:20:58 -0000 1.1
> --- xdocs/howto-use-anonymous-keys.xml 29 May 2003 14:18:23 -0000
> ***************
> *** 44,90 ****
>    public class Desk
>    {
>        private Finish finish;
> !
> !     /** Contains Thing instances */
> !     private Set drawers;
> !
>        private int numberOfLegs;
>
> !     public Set 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 }
> - }
> -
>    public class Drawer
>    {
> !     /** Contains anything */
> !     private Collection stuffInDrawer;
>
> !     public Collection getStuffInDrawer() { return
this.stuffInDrawer;
> }
>    }
> !
>    public class Finish
>    {
>        private String wood;
>        private String color;
>
> !     public String getWood()              { return this.wood; }
> !     public void setWood(String nom)      { this.wood = wood; }
> !
> !     public String getColor()             { return this.color; }
> !     public void setColor(String color)   { this.color = color; }
>    }
>
>    public class Thing
>    {
>        private String name;
>
> !     public String getName()              { return this.name; }
> !     public String setName(String name)   { this.name = name; }
>    }
>    ]]></source>
>    <p>
> --- 44,141 ----
>    public class Desk
>    {
>        private Finish finish;
> !     /** Contains Drawer instances */
> !     private List drawers;
>        private int numberOfLegs;
>
> !     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;
> !     }
> ! }
>
>
>    public class Drawer
>    {
> !     /** Contains Thing instances */
> !     private List stuffInDrawer;
>
> !     public List getStuffInDrawer()
> !     {
> !         return this.stuffInDrawer;
> !     }
> !
> !     public Drawer()
> !     {
> !         this.stuffInDrawer = new ArrayList();
> !     }
>    }
> !
> !
>    public class Finish
>    {
>        private String wood;
>        private String color;
>
> !     public String getWood()
> !     {
> !         return this.wood;
> !     }
> !
> !     public void setWood(String nom)
> !     {
> !         this.wood = wood;
> !     }
> !
> !     public String getColor()
> !     {
> !         return this.color;
> !     }
> !
> !     public void setColor(String color)
> !     {
> !         this.color = color;
> !     }
>    }
>
>    public class Thing
>    {
>        private String name;
>
> !     public String getName()
> !     {
> !         return this.name;
> !     }
> !
> !     public void setName(String name)
> !     {
> !         this.name = name;
> !     }
>    }
>    ]]></source>
>    <p>
> ***************
> *** 96,126 ****
>    When we need to store our instances in a database we use a fairly
> typical table per class persistance model.
>    </p>
>    <source><![CDATA[
>    CREATE TABLE desk
>    (
>        id          INTEGER PRIMARY KEY,
>        num_legs    INTEGER,
>    );
>
>    CREATE TABLE drawer
>    (
>        id          INTEGER PRIMARY KEY,
> !     desk_id     INTEGER FOREIGN KEY REFERENCES desk(id)
>    );
>
>    CREATE TABLE thing
>    (
>        id          INTEGER PRIMARY KEY,
>        name        VARCHAR(255),
> !     drawer_id   INTEGER FOREIGN KEY REFERENCES drawer(id)
> ! );
> !
> ! CREATE TABLE finish
> ! (
> !     id          INTEGER PRIMARY KEY,
> !     wood        VARCHAR(255),
> !     color       VARCHAR(255),
> !     desk_id     INTEGER FOREIGN KEY REFERENCES desk(id)
>    );
>    ]]></source>
>            <p>
> --- 147,180 ----
>    When we need to store our instances in a database we use a fairly
> typical table per class persistance model.
>    </p>
>    <source><![CDATA[
> + CREATE TABLE finish
> + (
> +     id          INTEGER PRIMARY KEY,
> +     wood        VARCHAR(255),
> +     color       VARCHAR(255)
> + );
> +
>    CREATE TABLE desk
>    (
>        id          INTEGER PRIMARY KEY,
>        num_legs    INTEGER,
> +     finish_id   INTEGER,
> +     FOREIGN KEY (finish_id) REFERENCES finish(id)
>    );
>
>    CREATE TABLE drawer
>    (
>        id          INTEGER PRIMARY KEY,
> !     desk_id     INTEGER,
> !     FOREIGN KEY (desk_id) REFERENCES desk(id)
>    );
>
>    CREATE TABLE thing
>    (
>        id          INTEGER PRIMARY KEY,
>        name        VARCHAR(255),
> !     drawer_id   INTEGER,
> !     FOREIGN KEY (drawer_id) REFERENCES drawer(id)
>    );
>    ]]></source>
>            <p>
> ***************
> *** 138,144 ****
>    <class-descriptor
>        class="Desk"
>        table="desk">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> --- 192,198 ----
>    <class-descriptor
>        class="Desk"
>        table="desk">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> ***************
> *** 152,175 ****
>            column="num_legs"
>            jdbc-type="INTEGER"
>            />
>        <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="deskId""/>
>        </reference-descriptor>
>    </class-descriptor>
>
>    <class-descriptor
>        class="Finish"
>        table="finish">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> --- 206,235 ----
>            column="num_legs"
>            jdbc-type="INTEGER"
>            />
> +     <field-descriptor
> +         name="finishId"
> +         column="finish_id"
> +         jdbc-type="INTEGER"
> +         access="anonymous" />
> +
>        <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
>        class="Finish"
>        table="finish">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> ***************
> *** 190,206 ****
>            jdbc-type="VARCHAR"
>            size="255"
>            />
> -     <field-descriptor
> -         name="deskId"
> -         column="desk_id"
> -         jdbc-type="INTEGER"
> -         />
>    </class-descriptor>
>
>    <class-descriptor
>        class="Drawer"
>        table="drawer">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> --- 250,261 ----
>            jdbc-type="VARCHAR"
>            size="255"
>            />
>    </class-descriptor>
>
>    <class-descriptor
>        class="Drawer"
>        table="drawer">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> ***************
> *** 226,232 ****
>    <class-descriptor
>        class="Thing"
>        table="thing">
> !
>        <field-descriptor
>            name="id"
>            column="id"
> --- 281,287 ----
>    <class-descriptor
>        class="Thing"
>        table="thing">
> !
>        <field-descriptor
>            name="id"
>            column="id"
>
>
>
>


------------------------------------------------------------------------
--------


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



Re: [PATCH] xdocs/howto-use-anonymous-keys.xml

Posted by Brian McCallister <mc...@forthillcompany.com>.
Bizarre, the attchements didn't make it through.

One more try, and the patch inline at the end.


[PATCH] xdocs/howto-use-anonymous-keys.xml

Posted by Brian McCallister <mc...@forthillcompany.com>.
I messed up the howto-use-anonymous-keys.xml howto, sorry about that. 
Didn't c&p final code in to the one I submitted.

Here is a (fully tested and working) patch for the howto, as well as 
the patched file (don't know which form is preferred).

-Brian