org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter
因为我的hibernate映射表没有主键所以报这个错。
解决方案是:
1、创建一个主键
2、hibernate处理无主键的表的映射问题,其实很简单,就是把一条记录看成一个主键,即组合主键<composite-id>。
注意:使用虚拟联合主键的话,实体类必须实现序列化接口:
org.hibernate.MappingException: Composite-id class must implement Serializable: cn.itcast.domain.Counter
< hibernate-mapping >
< class name = "com.cqgl.po.SaI18nLimitRulesPO" table = "SA_I18N_LIMIT_RULES" >
< composite-id >
< key-property name = "aircompanyCode" type = "java.lang.String" >
< column name = "AIRCOMPANY_CODE" />
</ key-property > < key-property name = "aircompanyName" type = "java.lang.String" >
< column name = "AIRCOMPANY_NAME" />
</ key-property > ...... </ composite-id >
</ class >
</ hibernate-mapping >
org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter的更多相关文章
- JPA error org.hibernate.AnnotationException: No identifier specified for entity
错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...
- Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...
- org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误
最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...
- org.hibernate.AnnotationException: No identifier specified for entity:
使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...
- org.hibernate.AnnotationException: No identifier specified for entity 错误解决
主键对应的属性上加上@Id注解,对应javax.persistence.Id @Id private Long id;
- 解决Entity 实体类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
启动报错如下图所示: 解决方案: 查看网上的资料,大部分都说在实体类中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查了很久,发现是我 ...
- Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
查看网上的资料,应该是报错的实体类com.example.domain.p.User中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查 ...
- hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误
hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibern ...
随机推荐
- ECMAScript 5.1中对属性的操作
此操作只针对新版本浏览器. Object.defineProperty(obj,'name',{configurable:true/false,enumberable:true/false,value ...
- CSS 知识积累
一.关于定位 1.相对定位下,不需要设定块级元素的宽度,只需要设定高度,即可以使该块级元素自适应,如果内有固定高度子元素,可以不设高度.而且可以进行top left定位. 2.相对定位下,如果两个兄弟 ...
- python 安装 管理包 pip
2.7的坑里出不来了,现在已经换到3.4了,不存在下列问题. win7下安装pip http://blog.chinaunix.net/uid-24984661-id-4202194.html ...
- C#中的 序列化和反序列化
什么是序列化和反序列化? 序列化就是把一个对象保存到一个文件或数据库字段中去,反序列化就是在适当的时候把这个文件再转化成原来的对象使用. 我想最主要的作用有: 1.在进程下次启动时读取上次保存的对象的 ...
- STL erase函数
1 各种迭代器erase实现 析构的基本工具 Template <class T> inline void destroy(T* pointer){ pointer->~T(); } ...
- 关于 RTMP RTMPT RTMPS RTMPE RTMPTE RTMFP AMF 简介
http://www.360doc.com/content/13/0709/16/21412_298738723.shtml 1. AMFAMF(是Action Message Format的缩写)是 ...
- 百度首页html代码
把百度设为主页 关于百度 About Baidu ©2015 Baidu 使用百度前必读 意见反馈 京ICP证030173号
- iOS开发--项目内存优化
在用非ARC模式编写iOS程序的时候,造成程序内存泄露在所难免,后期我们一般会进行内存优化.自己比较常用的内存优化方法有两种 1.Analyze,静态分析内存泄露的方法.很简单,在Xcode菜单栏中点 ...
- PHP组合模式、策略模式
一.问题 模拟不同课程有不同的收费方式,并且能灵活改变(新增或删减),如讲座可以固定收费也可改为按时收费,研讨会也是. 二.模式简介及关键点 1.在父类代码中使用条件语句是一种退倒,可以用多态来代替条 ...
- [Error]configure: error: Package requirements (fuse >= 2.3 glib-2.0 gthread-2.0) were not met:
No package 'fuse' found #sshfs是基于fuse模块的所以要安装fuse No package 'glib-2.0' found No packag ...