【问题标题】:Intellij Idea: Generate persistence mapping for HibernateIntellij Idea:为 Hibernate 生成持久性映射
【发布时间】:2013-10-18 01:22:15
【问题描述】:

我正在尝试使用 Intellij 生成 Hibernate hbm.xml 文件,但我在运行时遇到了这个问题:

ott 10, 2013 11:51:43 AM org.hibernate.internal.util.xml.ErrorLogger warning ERROR: HHH000198: Warning parsing XML (4) : schema_reference.4: lettura del documento di schema "http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd" non riuscita perché 1) non è stato possibile trovare il documento; 2) non è stato possibile leggere il documento; 3) l'elemento radice del documento non è <xsd:schema>.
...
ERROR: HHH000196: Error parsing XML (2) : cvc-elt.1: impossibile trovare la dichiarazione dell'elemento "hibernate-mapping".
Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML

生成的xml文件是这样的:

<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
    xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<class name="it.blackcat.hibernatedemo3.hdao.Actor" table="actor" schema="" catalog="sakila">
    <id name="actorId" column="actor_id"/>
    <property name="firstName" column="first_name"/>
    <property name="lastName" column="last_name"/>
    <property name="lastUpdate" column="last_update"/>
</class>

知道休眠映射有什么问题吗?谢谢!

编辑:

@LaGrandMere 解决了 DOCTYPE 的问题,但是...知道 Intellij 生成错误 XML 的原因吗?

【问题讨论】:

    标签: java hibernate intellij-idea


    【解决方案1】:

    你的

        xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd"
    

    不好。

    尝试:

    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    

    【讨论】:

    • 谢谢!它适用于您的文档类型,并且没有用于休眠映射的属性!我不明白为什么 Intellij 生成的 xml 是错误的......
    猜你喜欢
    • 2016-05-03
    • 2023-04-04
    • 1970-01-01
    • 2018-07-27
    • 2016-06-14
    • 2013-11-15
    • 2019-08-31
    • 2017-05-07
    • 2012-06-16
    相关资源
    最近更新 更多