无法在Hibernate中使用继承

时间:2011-01-04 16:56:23

标签: java database hibernate

请查看以下内容

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="com.att_marks.students.Attendance_Btech">
  <id name="id" type="integer" column="id" >
   <generator class="increment"/>
  </id>

  <property name="year">
     <column name="Year" />
  </property>
  <property name="semister">
    <column name="Semister"/>
  </property>
  <property name="section">
    <column name="Section"/>
  </property>
  <property name="period">
    <column name="Period"/>
  </property>
  <property name="subjectCode">
    <column name="Subject_Code"/>
  </property>
  <property name="date">
    <column name="Date"/>
  </property>
  <property name="status">
    <column name="Status"/>
  </property>
  <union-subclass name="com.att_marks.students.Attendance_Btech_ECE" table="attendance_btech_ece">

  </union-subclass>
 </class>
</hibernate-mapping>

我有名为attendance_btech_ece,attendance_btech_cse,attendance_btech_it等的表。所有这些表都使用与上述Attendance_Btech类相同的模式。我认为这应该有效,但事实并非如此。

1 个答案:

答案 0 :(得分:0)

如果Attendance_Btech_ECEAttendance_Btech的子类,那么应该可行。