新学hibenrnate,如下异常,希望高人指点一下
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/shang/madel/Student.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 com.shang.text.StudentText.main(StudentText.java:21)
Caused by: org.hibernate.MappingException: class Student not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:423)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:356)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
... 7 more
Caused by: java.lang.ClassNotFoundException: Student
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/shang/madel/Student.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 com.shang.text.StudentText.main(StudentText.java:21)
Caused by: org.hibernate.MappingException: class Student not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:423)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:356)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
... 7 more
Caused by: java.lang.ClassNotFoundException: Student
解决方案 »
- 求一个java对RTMP协议实现的Demo
- struts2
- hirbernate异常
- 如何解决Exception: AxisFault 401问题
- hibernate插入数据库时自增id值为null,新产生一个VO往数据库insert写入时,这个VO的id值总是为null,怎么样在它写入数据库后,取出表中的id
- 急,在线等待:使用weblogic 6.1,经常(大概一天一次)停止工作,甚至自动退出,不知什么原因?数据库连接在程序中都及时关闭了.
- 问一个ibatis中的一个问题
- Myeclipse 启动的时候总是如下错
- 大家一起来讨论讨论 Come on!
- Jboss4下使用Hibernate,搞了一天没出来?谁能提供一个完整的例子?
- 为什么不输出文本框啊 用jstl标签
- Struts2中找不到Globals.LOCALE_KEY????
private int id;
private String name;
private String age;
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;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
}
<?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="Student">
<id name="id"></id>
<property name="name"/>
<property name="age"/>
</class></hibernate-mapping>加空的构造方法还是不行,一样的错误的呀
还需要数据库有个student表,表的id是自增主键
还有Student类要实现序列化接口<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Student" table="student">
<id column="id" name="id">
<generator class="native"/>
</id>
<property column="name" name="name" type="java.lang.String"/> <property column="age" name="age" type="java.lang.String"/>
</class>
</hibernate-mapping>
<class name="Student">
必须加包名(如果<hibernate-mapping>没配置package的话)
<id name="id"></id>必须有生成策略<generator>好像是这么写,里面有个class="native"
试试