日期:2014-05-17  浏览次数:20775 次

初次接触Hibernate,老是出现 Unable to read XML的错误
hibernate.cfg.xml如下:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/demo
</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">
testDriver
</property>
<mapping resource="model/Xsb.hbm.xml" />

</session-factory>

</hibernate-configuration>


Xsb.hbm.xml文件如下:
<?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 ">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="model.Xsb" table="XSB" >
        <id name="xh" type="java.lang.String">
            <column name="XH" length="10" />
            <generator class="assigned" />
        </id>
        <property name="xsm" type="java.lang.String">
            <column name="XSM" length="20" not-null="true" />
        </property>
    </class>
</hibernate-mapping>

这些配置文件了,POJO类了什么的都是MyEclipse 10.6自动生成的…………



错误如下:
2013-4-27 20:41:13 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-4-27 20:41:13 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.4.Final}
2013-4-27 20:41:13 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2013-4-27 20:41:13 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-4-27 20:41:13 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2013-4-27 20:41:13 org.hibernate.cfg.Configuration getC