标签:
Hibernate继承(3)
前面已经看到两种继承关系,这一种继承关系是有程序来控制的继承,根部不能从数据表中看出两张表有继承关系,它的实现主要是在配置文件中指定父类的id的生成方法是Hilo的属性,同时还在在配置文件中用上<union-subclass>标签。
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping SYSTEM "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" > <!-- 采用每个具体类一张表 子类保存了继承的属性数据和自己扩展的属性数据 --> <hibernate-mapping package="bean"> <class name="Person" table="t_person" > <id name="id"><generator class="hilo"/></id> <property name="name"/> <property name="password"/> <property name="birthday"/> <union-subclass name="Student" > <property name="classId"/> <property name="className"/> <property name="course"/> </union-subclass> </class> </hibernate-mapping>
标签:
原文地址:http://www.cnblogs.com/aicpcode/p/4173666.html