当前位置: 首页 > 知识库问答 >
问题:

设置获取配置文件后,映射XML不验证

韦鸣
2023-03-14

基于留档,我在类中附加了获取配置文件。它不验证,我不知道为什么。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.mycompany.nncloudrestservice.model">
  <class name="User" table="users">
    <meta attribute="class-description">
        Description under construction
    </meta>
    <id name="id" type="int">
        <column name="id_user" not-null="true"/>
        <generator class="native"/>
    </id>
    <property name="login" column="login" type="string"/>
    <property name="email" column="email" type="string"/>
    <property name="password" column="password" type="string"/>
    <property name="activated" column="activated" type="boolean"/> 
    <property name="info_to_admin" column="info_to_admin" type="string"/>
    <property name="session_id" column="session_id" type="string"/>
    <property name="registered" column="registered" type="date"/>
    <bag name="networks" cascade="all" table="networks" inverse="true" lazy="true">
        <key column="id_user" not-null="true"/>
        <one-to-many class="Network"/>
    </bag>
    <fetch-profile name="user-with-networks">
      <fetch association="networks" style="join"/>
    </fetch-profile>
    <one-to-one name="performance_settings" cascade="all" class="PerformanceSettings"></one-to-one>
  </class>
</hibernate-mapping>

验证结果:

Element type "fetch-profile" must be declared. [23] 
Element type "fetch" must be declared. [24] 
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)*)". [27] 

非常奇怪的事情,尤其是在发现在DTD中显式声明了提取配置文件之后:

<!ELEMENT class (
    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*,
    fetch-profile*,
    resultset*,
    (query|sql-query)*
)>

共有1个答案

云骏奇
2023-03-14

Hibernate 3.5引入了fetch profile特性。在此之前,DTD不包含此标记。您的验证器很有可能捕获到过时的版本。根据这里的解决方案,您应该注意类路径上没有3.0 JAR。您可能还希望将SGML\U CATALOG\U文件(请参见此处)设置为DTD的本地副本,以便测试进一步的更改。

 类似资料:
  • XML 映射配置文件 MyBatis 的 XML 配置文件包含了影响 MyBatis 行为甚深的设置和属性信息。 XML 文档 的高层级结构如下: configuration 配置 properties 属性 settings 设置 typeAliases 类型命名 typeHandlers 类型处理器 objectFactory 对象工厂 plugins 插件 environments 环境 e

  • 我刚刚将我们的Spring Boot项目从引导升级到v2.6.2,从Spring Cloud升级到2021.0.0。 现在,我的远程配置获取没有任何效果,应用程序也无法获取正确的属性文件 [main]INFO o. s. c. c. c. ConfigServiceProperty tySourceLocator-从服务器获取配置:http://localhost:8080 [main]WARN

  • 本节描述了可用于映射器的各种配置模式。它假设你已经完成了 对象关系教程(1.x API) 并且知道如何构造和使用基本的映射器和关系。 映射Python类 声明性映射 非动态创建显式基础(与mypy一起使用,类似) 使用修饰符的声明性映射(无声明基) 具有数据类和属性的声明性映射 命令(又称经典)映射 具有数据类和属性的命令式映射 映射器配置概述 要映射的类 表或其他from子句对象 属性字典 其他

  • 另一个配置方法是在 hibernate.cfg.xml 文件中指定一套完整的配置。这个文件可以当成 hibernate.properties 的替代。若两个文件同时存在,它将覆盖前者的属性。 XML 配置文件被默认是放在 CLASSPATH 的根目录下。下面是一个例子: <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-conf

  • 4.5.2 launch文件设置话题重映射 launch 文件设置话题重映射语法: <node pkg="xxx" type="xxx" name="xxx"> <remap from="原话题" to="新话题" /> </node> 实现teleop_twist_keyboard与乌龟显示节点通信方案由两种: 1.方案1 将 teleop_twist_keyboard 节点的话题设置

  • X1.4.0新增 sp_get_plugin_config($name) 功能: 获取插件配置 参数: $name:插件名 返回: 类型数组,插件配置信息