疑难杂症:org.hibernate.MappingException: Unknown entity,annotation配置Entity类报错
引言:
夜声人静,外面下着稀里哗啦的雨,周末的晚上,还在键盘上舞动手指。
此刻很感激一个人一篇随笔,感谢xiaochao以及他的《org.hibernate.MappingException: Unknown entity常见问题(新手需注意)》,并由衷的对之所谓的苦B程序猿屌丝感到深深敬佩,我们不得不为如此为了解决一个问题,不得不去翻江倒海查找一个细节差错的精神,这就是屌丝程序猿的不为人知、不为人所动容的可爱之处。
好了,废话少说。
问题特征:
org.springframework.orm.hibernate3.HibernateSystemException: Unknown
entity:com.glb.devicem.modle.AdminVO
org.hibernate.MappingException: Unknown entity: com.glb.devicem.modle.AdminVO at
原因:
import Entity类造成的(使用Eclipse自动提示导入的该包),注解类引用错误
解决办法:
把导入的Entity类import org.hibernate.annotations.Entity改为import javax.persistence.Entity,问题解决。
参考:
【1】xiaochao.org.hibernate.MappingException: Unknown entity常见问题(新手需注意).http://www.blogjava.net/xiaochao/articles/hibernatetopic.html
参考内容如下:
最近学习Hiberante Annotations时遇到了该问题org.hibernate.MappingException: Unknown entity在baidu和googl上搜寻了 很久也没有找到适合我的解决方法,最后发现是import Entity类造成的(使用Eclipse自动提示导入的该包)
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Entity;//这是就出问题了哦
@Entity
@Table(name="test_person")
publicclass Person implements Serializable后面修改了引入的Entity
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Entity;//引入这个类就正确了
@Entity
@Table(name="test_person")
publicclass Person implements Serializable另外有些报org.hibernate.MappingException: Unknown entity,可能是没有在cfg文件中加入 *.hbm.xml造成的。
结束语:
因为经典,所以分享。因为后续一样会有苦B的程序猿掉入同样的坑,所以分享前车之鉴、前人之功。
疑难杂症:org.hibernate.MappingException: Unknown entity,annotation配置Entity类报错的更多相关文章
- org.hibernate.MappingException: Unknown entity
org.hibernate.MappingException: Unknown entity 原因1: 异常是因为使用注解的时候没有导入正确的包.要清楚,Entity包是javax.persisten ...
- 令人哭笑不得的org.hibernate.MappingException: Unknown entity
今天处理的任务是从一套系统中分离出微信易信功能代码添加到另一套系统中..本来是一个很简单的任务,但是分离移植过去后,一运行报了个错: nested exception is org.hibernate ...
- spring 整合hibernate注解时候,出现“Unknown entity: com.ssh.entry.Admin; nested exception is org.hibernate.MappingException: Unknown entity: com.ssh.entry.Admin”异常的问题
今天学习使用ssh框架的时候,出现一个异常,弄了好久才找到,在这记录一下,我的sb错误1.spring整合hibernate,取代*.hbm.xml配置文件 在applicationContext ...
- org.hibernate.MappingException:Unknown entity:java.util.ArrayList
1.错误描述 [CQ] ERROR [http-apr-8888-exec-3] com.opensymphony.xwork2.util.logging.commons.CommonsLogger. ...
- Exception 03 : org.hibernate.MappingException: Unknown entity: org.hibernate.cfg.Configuration
异常名称 org.hibernate.MappingException: Unknown entity: org.hibernate.cfg.Configuration 异常详细信息 org.hibe ...
- 关于Hibernate的报错org.hibernate.MappingException: Unknown entity
部分异常,如下 org.hibernate.MappingException: Unknown entity: com.zcd.hibernate.oneToMany.Teamat org.hiber ...
- 错误/异常:org.hibernate.MappingException: Unknown entity: com.shore.entity.Student 的解决方法
1.错误/异常视图 错误/异常描述:Hibernate配置文件 映射异常,不明实体类Student(org.hibernate.MappingException: Unknown entity: co ...
- 关于Entity Framework中的Attached报错相关解决方案的总结
关于Entity Framework中的Attached报错的问题,我这里分为以下几种类型,每种类型我都给出相应的解决方案,希望能给大家带来一些的帮助,当然作为读者的您如果觉得有不同的意见或更好的方法 ...
- 关于Entity Framework中的Attached报错的完美解决方案终极版
之前发表过一篇文章题为<关于Entity Framework中的Attached报错的完美解决方案>,那篇文章确实能解决单个实体在进行更新.删除时Attached的报错,注意我这里说的单个 ...
随机推荐
- hadoop2.2伪分布安装加2.2源码编译
配置linux基本环境: --> java.ip.hostname.hosts.iptables.chkconfig.ssh环境配置 hadoop2.2安装在linux64位机器上,需要对源码进 ...
- HW7.15
public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...
- js运动 摩擦运动
<!DOCTYPE HTML> <HTML> <meta http-equiv="Content-Type" content="text/h ...
- 轻松学习Linux之认识内存管理机制
本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- ArrayList中元素去重问题
如题所示,如果一个ArrayList中包含多个重复元素,该如何去重呢? 思路一以及实现: 声明2个ArrayList,分别为listA与listB ,listA为待去重list ,listB 保存去重 ...
- KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594
riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...
- 使用python通过SSH登陆linux并操作
用的昨天刚接触到的库,在windows下通过paramiko来登录linux系统并执行了几个命令,基本算是初试成功,后面会接着学习的. 代码: >>> import paramiko ...
- CodeForces 709B Checkpoints (数学,最短路)
题意:给定你的坐标,和 n 个点,问你去访问至少n-1个点的最短路是多少. 析:也是一个很简单的题,肯定是访问n-1个啊,那么就考虑从你的位置出发,向左访问和向右访问总共是n-1个,也就是说你必须从1 ...
- Linux下生成动态链接库是否必须使用 -fPIC 的问题[转]
在 Linux 下制作动态链接库,“标准” 的做法是编译成位置无关代码(Position Independent Code,PIC),然后链接成一个动态链接库.经常遇到的一个问题是 -fPIC 是不是 ...
- UI:自定义键盘的实现
自定义我的封装键盘,并在试图控制器里对接 (解决多 输入框问题,把输入框存入到可变数组) @implementation AppDelegate - (BOOL)application:(UIAppl ...