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 ...
随机推荐
- 11gR2数据库日志报错:Fatal NI connect error 12170、
11gR2数据库日志报错:Fatal NI connect error 12170.TNS-12535.TNS-00505 [问题点数:100分,结帖人MarkIII] 不显示 ...
- 分布式数据存储-MySQL主从复制
前言 一.主从复制过程 MySQL的主从复制能力是通过三个线程来实现的,两个在Slave端的I/O和SQL两个线程,还有一个在Master端I/O线程: Binlog dump thread:Mast ...
- HDU 1671 Phone List(字符处理)
题目 用字典树可以过,可是我写的字典树一直各种错误,,, 所以,我用了别的更简便的方法.. //去你妹的一直有问题的字典树!!! ////字典树,树的根是空的 // ////#include<i ...
- swift-网络请求
跟着网上大神写了个,还有待提高啊:http://pan.baidu.com/s/1sjC5Pl7
- React.js 样式组件:React Style
点这里 React Style 是 React.js 可维护的样式组件.使用 React Native StyleSheet.create一样的样式. 完全使用 JavaScript 定义样式: ? ...
- com组件的注册
错误: 检索 COM 类工厂中 CLSID 为 {79AD7B73-C515-40B4-8B02-CB0F5FA5A1A8} 的组件失败,原因是出现以下错误: 80040154 没有注册类 (异常来自 ...
- (2)jni编程学习笔记
先说说NDK和jni的关系吧,这两个看起来挺容易搞混的 我到网上也查了一些资料: java的jni提供了一个调用c语言函数的接口,其实就是一个java函数,这个函数没有任何内容,这个函数调用时直接进入 ...
- 李洪强iOS开发之- 实现简单的弹窗
李洪强iOS开发之- 实现简单的弹窗 实现的效果: 112222222222223333333333333333
- IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践
原文:IntelliJ IDEA:Getting Started with Spring MVC, Hibernate and JSON实践 最近把编辑器换成IntelliJ IDEA,主要是Ecli ...
- 使用原生JavaScript
如果你只需要针对现代浏览器,很多功能使用原生的 JavaScript 就可以实现. DOM Selectors //jQuery var ele = $("#id .class") ...