+ -
当前位置:首页 → 问答吧 → 求助Hibernate报错: org.hibernate.MappingException: Unknown entity: com.hibernate.be

求助Hibernate报错: org.hibernate.MappingException: Unknown entity: com.hibernate.be

时间:2011-10-04

来源:互联网

hibernate.cgf.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<mapping resource="hibernate.cfg.xml" />
</session-factory>
</hibernate-configuration>
-------------------------------------------------------------------------------------------------------------
Student.hbm.xml配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.hibernate.bean">
<class name="Student" table="student">
<id name="id">
</id>
<property name="name" />
</class>
</hibernate-mapping>
-------------------------------------------------------------------------------------------------------------
package com.hibernate.bean;

public class Student {

private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

}

作者: shamegold2   发布时间: 2011-10-04

<mapping resource="hibernate.cfg.xml" />
这一段配置、换成你的Student.hbm.xml配置文件
XML code

<mapping resource="com/hibernate/bean/Student.hbm.xml" />

作者: hzw2312   发布时间: 2011-10-04

需要把类的映射文件加载到hibernate.cfg.xml

作者: huangchenliang   发布时间: 2011-10-04

热门下载

更多