Date: 2005-02-03T16:56:23
   Editor: MichelleCaisse
   Wiki: Apache JDO Wiki
   Page: MetadataMappings
   URL: http://wiki.apache.org/jdo/MetadataMappings

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -25,8 +25,55 @@
 
 '''Question:''' What about index element or indexed attribute of 
<discriminator>? These are in the dtd, but not mentioned in 
Chapter18TestCoverageNotes.
 
+'''Note:''' I think we need some examples for inheritance in Chapter 15.
+
 Combining inheritance pattern with discriminator strategy, there are four 
cases that must be tested.  Because there are two inheritance hierarchies in 
the Company model, we require only two different mappings to cover the four 
cases.
 
 = <join> =
+Any class in the Company model could be stored in two tables that are then 
joined. However, there are no obvious candidates where this really makes sense 
in terms of design. Note that there is also no obvious place to use a compound 
primary key in the Company model, so that functionality should be included in 
another model.
 = <embedded> =
+Chapter18TestCoverageNotes states that we will test <class embedded-only> in 
the Company model Completeness test. I assume that means we will test the case 
where embedded-only is true. The simplest case is to embed Address in both 
Company and Department.  Address is the only class in the Company model that is 
neither a subclass nor contains a reference to another class in the model.
+== Embedding a subclass ==
+The three patterns of inheritance allow for the data of a subclass to be 
stored in the superclass table, its own table along with all the fields of the 
superclass, or in its own table with only the subclass fields stored.  Is it 
possible to store a subclass class embedded in another class?  What would the 
metadata look like?
+== Embedding a class holding a reference to another class ==
+Can you have nested embedding or relatioship mapping nested in an <embedded> 
element?
+Consider embedding Company in the department class:
+  <class name="Department" table="department">
+      <field name="deptid" column="deptid"/>
+      <field name="name" column="name"/>
+      <!-- Company field -->
+      <embedded>
+         <field name="companyid" column"companyid">
+         <field name="name" column"name">
+         <field name="founded" column"founded">
+         <!-- Address field of Company class-->
+         <embedded>
+            <field name="addrid" column="addrid">
+            <field name="street" column="street">
+            <field name="city" column="city">
+            <field name="state" column="state">
+            <field name="zipcode" column="zipcode">
+            <field name="country" column="country">
+         </embedded>
+      </embedded>
+  </class>
+Alternatively, might we embed Company in Employee, but store Adress in its own 
class:
+   <class name="Department" table="department">
+      <field name="deptid" column="deptid"/>
+      <field name="name" column="name"/>
+      <!-- Company field -->
+      <embedded>
+         <field name="companyid" column="companyid">
+         <field name="name" column"name">
+         <field name="founded" column="founded">
+         <!-- Address field of Company class - addrid is foreign key to 
address table-->
+         <field name="address" column="addrid">
+      </embedded>
+   </class>
+   <!-- map Address field to the address table -->
+   <class name="Address" table="address"
+        ...
+   </class>
+If these two types of mappings are possible, they should be tested.
 = Relationships =
+There are many relationships in the Company model that can be mapped as shown 
on RelationshipsManyToOne and RelationshipsOneToMany. While these present some 
interesting parsing challenges for the implementation, the only 
relationship-specific tag to be tested is <element>.

Reply via email to