Roberto Girelli
Roberto Girelli

Reputation: 25

Intellij Idea: Generate persistence mapping for Hibernate

I'm trying to generate Hibernate hbm.xml files with Intellij but i have this problem at runtime:

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

The generated xml file is this:

<?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>

Any idea what's wrong in hibernate-mapping?? Thanks!

EDIT:

@LaGrandMere solved the problem with DOCTYPE but... any idea why Intellij generates wrong XML?

Upvotes: 1

Views: 2490

Answers (1)

LaGrandMere
LaGrandMere

Reputation: 10359

Your

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

is not good.

Try with:

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

Upvotes: 2

Related Questions