Differences between revisions 10 and 11
Revision 10 as of 2005-10-13 23:35:14
Size: 2216
Comment:
Revision 11 as of 2009-09-20 23:08:54
Size: 2216
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Default mapping

Notes

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.

MetadataMappings (last edited 2009-09-20 23:08:54 by localhost)