首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate-承继映射

2012-11-15 
Hibernate----继承映射public class Person implements Serializable {private Integer personId//姓名pr

Hibernate----继承映射
public class Person implements Serializable {
    private Integer personId;
    //姓名
private String personName;
//性别
private String sex;
//联系电话
private String phone;
    //相应的setter,getter
}
person.xml:(含子类Doctor)
<class name="com.yang.model.human.Person" table="t_person">
<id name="personId" column="person_id">
<generator />
</id>
<discriminator type="string" column="personType"></discriminator>
<property name="personName" />
<property name="sex" />
<property name="phone"></property>

   <subclass name="com.yang.model.human.Doctor"  discriminator-value="doctor">
               <property name="password" />
               <many-to-one name="technicalOffice" column="officeid"  />
               <one-to-one name="workTime" constrained="true"/>
        </subclass>

</class>

Doctor类:(与TechnicalOffice 是双向一对多)
private String password;
//医生所属的科室
private TechnicalOffice technicalOffice;
//医生的工作时间
private WorkTime workTime;

热点排行