hibernate映射xml有什么问题?

时间:2013-06-08 09:06:54

标签: java hibernate java-ee hibernate-mapping

当我验证以下xml时,出现以下错误:

The content of element type "class" must match "(meta*,subselect?,cache?,
synchronize*,comment?,tuplizer*,(id|composite-id),
discriminator?,natural-id?,(version|timestamp)?,
(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map
|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|
union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,
(query|sql-query)*)". [16]

我得到这个的原因是什么?

 <hibernate-mapping>
  <class name="pojo.Parent" table="student_detail">
      <id name="roll_number">
          <generator class="increment" />
      </id>
      <property name="s_name" />
      <discriminator column="discrim" type="string" />
      <subclass name="pojo.Child">
          <property name="hindi" />
          <property name="english" />
          <property name="punjabi" />
          <property name="total" />
      </subclass>
  </class>    
  </hibernate-mapping>

1 个答案:

答案 0 :(得分:1)

元素的顺序是错误的。

discriminator置于id之后。

查看示例here