Hi Michelle,

On Aug 1, 2005, at 3:32 PM, Michelle Caisse wrote:

Hi Craig,

Could you take a look at my proposed mapppings and schema below?  I have a few specific questions at the relevant places below.

0. Use a join table, and use foreign keys for the elements to refer to the primary table
1. Use a join table, and embed the elements column by column
2. Use a join table, and serialize the elements
3. Serialize the entire ArrayList.


Currently we have, taking ArrayListCollections as an example:
 public static final String [] fieldSpecs = {
 "public ArrayList ArrayListOfObject0",
 "embedded-element=true public ArrayList ArrayListOfObject1",
 "embedded-element=false public ArrayList ArrayListOfObject2",
...
}

We want:
 public static final String [] fieldSpecs = {
 "public ArrayList ArrayListOfObject0",   [ArrayList in join table, elements in join tables]
 "embedded-element=true public ArrayList ArrayListOfObject1",   [ArrayList in join table, elements embedded]
 "embedded-element=false <element serialized=true> public ArrayList ArrayListOfObject2",   [ArrayList in join table, elements serialized]
 "serialized=true public ArrayList ArrayListOfObject3",  [ArrayList serialized in columns of primary table]

** QUESTION: I'm not sure how much to attempt to test defaults (unspecified values for embedded-element, serialized.

You have the default case in ArrayListOfObject0. It defaults to serialized=false, embedded-element=false, using a join table.

What you don't have is the explicit serialized=false, embedded-element=false. I don't know that it's important.

______
orm:

<orm>
   <package name="org.apache.jdo.tck.pc.fieldtypes">
       <class name="ArrayListCollections" table="ARRAYLIST_COLLECTIONS">
           <field name="identifier" column="IDENTIFIER" primary-key="true"/>
           <field name="ArrayListOfObject0"
                  table="ARRAYLIST_OF_OBJECT0">
               <join column="IDENTIFIER"/>
               <element column="OBJREF">
                    <foreign-key/>
               </element>
               <order column="INDEX"/>
           </field>
           <field name="ArrayListOfObject1"
                  table="ARRAYLIST_OF_OBJECT1">
                <element>
                    <embedded>
                      <field="intval" column="INTVAL"/>
                      <field="stringval" column="STRINGVAL"/>
                   </embedded>
                </element>
              <order column="INDEX"/>
           </field>
           <field name="ArrayListOfObject2"
                  table="ARRAYLIST_OF_OBJECT2">
               <join column="IDENTIFIER"/>
               <element column="OBJVAL" serialized="true"/>
               <order column="INDEX"/>
           </field>
            <!-- QUESTION: Is it necessary to specify serialized="true" for this field? -->

Yes, because serialized=true is not (ever) the default for a field.

           <field name="ArrayListOfObject3"
                  column="ARRAYLIST_OF_OBJECT3" serialized="true">
           </field>
...
______
jdo:

<jdo>
<package name="org.apache.jdo.tck.pc.fieldtypes">
<class name="ArrayListCollections" identity-type="application"
   objectid-class="org.apache.jdo.tck.pc.fieldtypes.ArrayListCollections$Oid">
<field name="identifier" primary-key="true"/>
<field name="ArrayListOfObject0" >
<collection element-type="java.lang.Object">
</collection>
</field>
<field name="ArrayListOfObject1" >
<collection element-type="java.lang.Object" embedded-element="true">
</collection>
</field>
<field name="ArrayListOfObject2" >
<!-- QUESTION: Is embedded-element true, false, or n/a?? -->

It's n/a. The mapping is embedded serialized so this doesn't matter.

Craig


<collection element-type="java.lang.Object" embedded-element="false">
</collection>
</field>
<field name="ArrayListOfObject3" >
<collection element-type="java.lang.Object">
</collection>
</field>
...
______
Schema:

CREATE TABLE ARRAYLIST_COLLECTIONS
(
   IDENTIFIER INTEGER NOT NULL,
   ARRAYLIST_OF_OBJECT3 LONG VARCHAR FOR BIT DATA,
   ARRAYLIST_OF_SIMPLE_CLASS3 LONG VARCHAR FOR BIT DATA,
   ARRAYLIST_OF_SIMPLE_INTERFACE3 LONG VARCHAR FOR BIT DATA,
   ...
);

-- element neither serialized nor embedded
CREATE TABLE ARRAYLIST_OF_OBJECT-
(
   IDENTIFIER INTEGER REFERENCES ARRAYLIST_COLLECTIONS NOT NULL,
   OBJREF BIGINT REFERENCES SIMPLE_CLASS NOT NULL,
   INDEX INTEGER NOT NULL
);

-- embedded-element="true"
CREATE TABLE ARRAYLIST_OF_OBJECT1
(
   IDENTIFIER INTEGER REFERENCES ARRAYLIST_COLLECTIONS NOT NULL,
   INTVAL INTEGER NOT NULL,
   STRINGVAL VARCHAR(128) NOT NULL,
   INDEX INTEGER NOT NULL
);

-- <element serialized="true">
CREATE TABLE ARRAYLIST_OF_OBJECT2
(
   IDENTIFIER INTEGER REFERENCES ARRAYLIST_COLLECTIONS NOT NULL,
   OBJVAL LONG VARCHAR FOR BIT DATA,
   INDEX INTEGER NOT NULL
);

Thanks!

-- Michelle


Craig Russell

Architect, Sun Java Enterprise System http://java.sun.com/products/jdo

408 276-5638 mailto:Craig.Russell@sun.com

P.S. A good JDO? O, Gasp!