mikehsieh wrote:
I follow the tutorial to create Event.hbm.xml but I got the error when I run it.
[java] 15:55:54,746 INFO Configuration:559 - Reading mappings from resource : events/Event.hbm.xml
[java] 15:55:54,756 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document is invalid: no grammar found.
[java] 15:55:54,766 ERROR XMLHelper:61 - Error parsing XML: XML InputStream(2) Document root element "hibernate-mapping", must match DOCTYPE root "null".
[java] Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource events/Event.hbm.xml
Here's the contents in Event.hbm.xml
<hibernate-mapping>
<class name="events.Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="native"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>
</hibernate-mapping>
Yes, to clarify, what we've both left out is the XML header, which looks like this:
Quote:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
...and goes just above the <hibernate-mapping>...etc.
Once that's in, it sorts it out nicely. It's mentioned in the tutorial but because the whole file isn't quoted as one piece, us copy-pastafarians end up copying half a file.