首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate报如上异常: org.hibernate.MappingException: Unknown entity: 解决

2012-11-10 
Hibernate报如下错误: org.hibernate.MappingException: Unknown entity: 解决控制台报错:Caused by: org.

Hibernate报如下错误: org.hibernate.MappingException: Unknown entity: 解决
控制台报错:

Caused by: org.hibernate.MappingException: Unknown entity: com.SpringMvcTest.model.Questions
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)


分析:

      这个异常的意思就是某个类没有被映射。

这里是  com.SpringMvcTest.model.Questions类

解决方法:

       需要把类的映射文件加载到hibernate.cfg.xml (如果是spring mvc 看看加載的.cfg.xml 方式有么有錯)
我的原先是:
<property name="mappingDirectoryLocations">
<list>
<!--  <value>classpath:/config/hibernate</value>  Mysql -->
  <value>classpath:/config/hibernate/a</value> <!--Ms sql -->
</list>
</property>



热点排行