第一个hilernate 遇到的问题请教大家帮帮忙

我心java 发布于 2012/03/08 16:11
阅读 826
收藏 0

Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/bjsxt/cm/cn/Student.hbm.xml
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4009)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3998)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3986)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
 at com.bjsxt.cm.cn.StudentTest.main(StudentTest.java:20)
Caused by: org.hibernate.MappingException: class com.bjsxt.cm.cn.hibernate1 not found while looking for property: id
 at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
 at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:316)
 at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:454)
 at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:387)
 at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:326)
 at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:177)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4006)
 ... 5 more
Caused by: java.lang.ClassNotFoundException: com.bjsxt.cm.cn.hibernate1
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:169)
 at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
 at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228)
 ... 11 more

 

<hibernate-mapping package="com.bjsxt.cm.cn">
<class name="hibernate1" table="student">
   <id name="id"></id>
   <property name="name"></property>
   <property name="age"></property>
 </class>
</hibernate-mapping>

 

 


        <mapping resource="com/bjsxt/cm/cn/Student.hbm.xml"/>

    </session-factory>

加载中
0
double9
double9
<class name="hibernate1" table="student">
   <id name="id"></id>
   <property name="name"></property>
   <property name="age"></property>
 </class>
class的name 属性是你的po对象 从你给的信息来看的话 name应该是Student
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部