l 继承映射
对象模型(Java类结构)
一个类继承体系一张表(subclass)(映射文件)
<class name="Employee" table="employee" discriminator-value="0">
<id name="id">
<generator class="native"/>
</id>
<discriminator column="type" type="int"/>
<property name="name"/>
<many-to-one name=”depart” column=”depart_id”/>
<subclass name="Skiller" discriminator-value="1">
<property name=”skill”/>
</subclass>
<subclass name="Sales" discriminator-value="2">
<property name="sell"/>
</subclass>
</class>
每个子类一张表(joined-subclass) (映射文件)
<class name="Employee" table="employee">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<joined-subclass name="Skiller" table="skiller">
<key column="employee_id"/>
<property name="skill"/>
</joined-subclass>
<joined-subclass name="Sales" table="sales">
<key column="employee_id"/>
<property name="sell"/>
</joined-subclass>
</class>
混合使用“一个类继承体系一张表”和“每个子类一张表” (映射文件)
<class name="Employee" table="employee">
<id name="id">
<generator class="native"/>
</id>
<discriminator column="type"/>
<property name="name"/>
<subclass name="Skiller">
<property name="net"/>
</subclass>
<subclass name=”Sales”">
<join table="sales">
<key column="employee_id"/>
<property name="sell"/>
</join>
</subclass>
</class>
每个具体类一张表(union-subclass) (映射文件)
<class name="Employee" abstract="true">
<id name="id">
<generator class="hilo"/>
</id>
<property name="name"/>
<union-subclass name="Skiller" table="skiller">
<property name="skill"/>
</union-subclass>
<union-subclass name="Sales" table="sales">
<property name="sell"/>
</union-subclass>
</class>
主健不能是identity类型,如果父类是abstract=”true”就不会有表与之对应。
隐式多态,映射文件没有联系,限制比较多很少使用。