【问题标题】:what is wrong with the hibernate mapping xml?休眠映射xml有什么问题?
【发布时间】:2013-06-08 09:06:53
【问题描述】:

当我验证以下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>

【问题讨论】:

    标签: java hibernate jakarta-ee hibernate-mapping


    【解决方案1】:

    元素顺序错误。

    discriminator 紧跟在id 之后。

    看看例子here

    【讨论】:

    • 为什么顺序很重要?
    • 为什么这很重要?关键是它确实如此,除非订单正确,否则文件将不会验证。也许当休眠读取映射时,首先读取鉴别器更容易?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-29
    • 2011-01-31
    • 2014-05-12
    • 2021-01-13
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    相关资源
    最近更新 更多