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 2003/05/30 14:48:33 UTC
cvs commit: db-ojb/xdocs howto-use-anonymous-keys.xml project.xml
arminw 2003/05/30 05:48:32
Modified: xdocs howto-use-anonymous-keys.xml project.xml
Log:
add patch by Brain McCallister
Revision Changes Path
1.2 +98 -43 db-ojb/xdocs/howto-use-anonymous-keys.xml
Index: howto-use-anonymous-keys.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/howto-use-anonymous-keys.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- howto-use-anonymous-keys.xml 15 May 2003 06:20:58 -0000 1.1
+++ howto-use-anonymous-keys.xml 30 May 2003 12:48:32 -0000 1.2
@@ -44,47 +44,98 @@
public class Desk
{
private Finish finish;
-
- /** Contains Thing instances */
- private Set drawers;
-
+ /** Contains Drawer instances */
+ private List drawers;
private int numberOfLegs;
- public Set getDrawers() { return this.drawers; }
+ 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 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;
+ /** Contains Thing instances */
+ private List stuffInDrawer;
- public Collection getStuffInDrawer() { return this.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 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; }
+ public String getName()
+ {
+ return this.name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
}
]]></source>
<p>
@@ -96,31 +147,34 @@
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 REFERENCES desk(id)
+ 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 REFERENCES drawer(id)
-);
-
-CREATE TABLE finish
-(
- id INTEGER PRIMARY KEY,
- wood VARCHAR(255),
- color VARCHAR(255),
- desk_id INTEGER FOREIGN KEY REFERENCES desk(id)
+ drawer_id INTEGER,
+ FOREIGN KEY (drawer_id) REFERENCES drawer(id)
);
]]></source>
<p>
@@ -138,7 +192,7 @@
<class-descriptor
class="Desk"
table="desk">
-
+
<field-descriptor
name="id"
column="id"
@@ -152,24 +206,30 @@
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="deskId""/>
+ <foreignkey field-ref="finishId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="Finish"
table="finish">
-
+
<field-descriptor
name="id"
column="id"
@@ -190,17 +250,12 @@
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"
@@ -226,7 +281,7 @@
<class-descriptor
class="Thing"
table="thing">
-
+
<field-descriptor
name="id"
column="id"
1.17 +2 -1 db-ojb/xdocs/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/db-ojb/xdocs/project.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- project.xml 8 May 2003 06:08:08 -0000 1.16
+++ project.xml 30 May 2003 12:48:32 -0000 1.17
@@ -43,7 +43,8 @@
<item name="get started" href="/howto-get-started.html"/>
<item name="use DB Sequences" href="/howto-use-db-sequences.html"/>
<item name="use Oracle lobs" href="/howto-use-lobs.html"/>
- <item name="use Stored Procedures" href="/how-to-work-with-stored-procedures.html"/>
+ <item name="use Stored Procedures" href="/how-to-work-with-stored-procedures.html"/>
+ <item name="use anonymous keys" href="/howto-use-anonymous-keys.html"/>
</menu>