映射XML不会';设置获取配置文件后无法验证
基于,我在类中附加了fetch配置文件。 它无法验证,我也不知道为什么映射XML不会';设置获取配置文件后无法验证,xml,hibernate,dtd,Xml,Hibernate,Dtd,基于,我在类中附加了fetch配置文件。 它无法验证,我也不知道为什么 <?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 pac
<?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>
非常奇怪的事情,尤其是在发现在DTD中显式声明了fetch配置文件之后:
<!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)*
)>
Hibernate 3.5引入了提取配置文件功能。在此之前,DTD不包含此标记。您的验证器捕捉到过时版本的可能性非常高。 根据这里的说明,您应该注意类路径上没有3.0 JAR。
您可能还希望将SGML_CATALOG_FILES()设置为DTD的本地副本,以便测试进一步的更改。您使用什么来验证?验证结果中的内容模型与DTD不匹配,因此公共标识符似乎正在解析为不同的DTD。您是否可以发布任何其他堆栈跟踪?@DanielHaley我使用了默认的netbeans验证器和一些在线工具,结果完全相同。如何获取附加堆栈跟踪?您确定错误消息完全相同吗?如果使用了系统标识符()中指定的DTD,您仍然会得到错误,但这是因为
one-to-one
需要在fetch profile
之前出现。(尝试交换它并再次在您的一个在线工具中验证。)@DanielHaley尝试了它,但没有任何更改,也没有在将获取配置文件移到类外后进行更改。您是否尝试了session.enableFetchProfile(“有网络的用户”)代码>在您的操作之前?
<!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)*
)>