我是Hibernate的新手。我的Hibernate项目中有一个例外,我认为是由于我的Lecteurs.hbm.xml文件。
我需要你的帮助。 感谢。
例外情况如下:
958 [main] ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(13) need whitespace between attributes
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource bean/Lecteurs.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:21)
at manager.LecteursManager.ajouterLecteur(LecteursManager.java:13)
at test.Test_Main.main(Test_Main.java:18)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource bean/Lecteurs.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:616)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at util.HibernateUtil.<clinit>(HibernateUtil.java:15)
... 2 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:555)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
... 9 more
Caused by: org.dom4j.DocumentException: Error on line 13 of document : need whitespace between attributes Nested exception: need whitespace between attributes
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:546)
... 10 more
下面是映射文件Lecteurs.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >
<class name="bean.Lecteurs" table="LECTEURS">
<id name="id" type="int" column="ID" >
<generator class="increment"/>
</id>
<property name="nom_lecteur" type="string" column="nomLecteur" />
<property name="prenom_lecteur"" type="string" column="prenomLecteur" />
<property name="date_naissance" type="Date" column="dateNaissance" />
<property name="email_lecteur" column="emailLecteur" ></property>
<property name="telephone" column="telephoneLecteur" ></property>
<property name="adresse" column="adresseLecteur" ></property>
</class>
</hibernate-mapping>
答案 0 :(得分:1)
此行中连续有两个双引号,可能会导致该错误:
<property name="prenom_lecteur"" type="string" column="prenomLecteur" />