java - hibernate映射xml有什么问题?

标签 java hibernate jakarta-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>

最佳答案

元素的顺序错误。

鉴别器放在id之后。

看一下示例 here .

关于java - hibernate映射xml有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16997878/

相关文章:

java - 服务器启动时在 Web 应用程序中获取服务器端口

Java错误: not a statement with charsequence variable

hibernate - 如何在条件中使用 'in' 来查询子对象?

java - 如何将我的表单与操作链接起来?

java - Spring应用程序找不到hbm.xml映射文件

java - 如何使用 Java 和 Hibernate 按特定列对 MySQL 查询进行排序?

java - @生产者的 CDI @inject 失败

java计算器小数点

java - Eclipse 中的 @NonNullByDefault 和 @Nullable 求值

java - 在 firebase 中上传后,保存在数据库中的图像链接不起作用