Default mapping

*MappingCollections
*DefaultMappingMetadata
*DefaultDdl
*EmployeeInsuranceMapping

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.

  • No labels