Hibernate:InvalidMappingException

时间:2015-02-19 08:54:27

标签: java swing hibernate

我正在使用hibernate框架用于桌面应用程序(Swing),我为hibernte调用了所需的库,但我在创建SessionFactory时仍然遇到此异常:

private static SessionFactory factory = new Configuration(). configure(). buildSessionFactory();

enter image description here

这是使用过的图书馆清单:
enter image description here

我的配置文件:

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

1 个答案:

答案 0 :(得分:0)

尝试从config和hbm文件中的顶级标记中删除编码部分。

我不确定这对你有用,对我们有用。