我将hibernate框架用于桌面应用程序(Swing),并调用了hibernte工作所需的库,但在创建SessionFactory时仍然会遇到此异常
private static SessionFactory factory = new Configuration(). configure(). buildSessionFactory();

这是使用过的库的列表:

我的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</property>
<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost:5432/test_hibernate
</property>
<property name="hibernate.connection.username">
postgres
</property>
<property name="hibernate.connection.password">
root
</property>
<mapping resource="Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>我的映射文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Employee" table="employee">
<meta attribute="class-description">
This class contains the employee detail.
</meta>
<id name="id" type="int" column="id">
<generator class="native"/>
</id>
<property name="name" column="name" type="string"/>
<property name="salary" column="salary" type="double"/>
</class>
</hibernate-mapping>发布于 2015-04-06 19:03:25
尝试从config和hbm文件的顶级标记中删除编码部分。
我不确定这是否对你有效,它对我们有效。
https://stackoverflow.com/questions/28602026
复制相似问题