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 ...
随机推荐
- linux下命令行查看Memcached运行状态(shell)
stats查看memcached状态的基本命令,通过这个命令可以看到如下信息:STAT pid 22459 进程IDSTAT uptime 10 ...
- 关于iOS7 上下黑条解决办法
解决办法 找到工程的targest->General->Launch Image Sourse OK 运行问题解决
- Razor视图引擎 语法学习(一)
ASP.NET MVC是一种构建web应用程序的框架,它将一般的MVC(Model-View-Controller)模式应用于ASP.NET框架: ASP.NET约定优于配置:基本分为模型(对实体数据 ...
- 分布式 Key-Value 存储系统:Cassandra 入门
Apache Cassandra 是一套开源分布式 Key-Value 存储系统.它最初由 Facebook 开发,用于储存特别大的数据. Cassandra 不是一个数据库,它是一个混合型的非关系的 ...
- Linux基础--用户和组管理
1.账号管理相关文件 1)/etc/passwd 每一行都代表一个账号,有几行就代表有几个账号在你的系统中,不过需要特别留意的是,里头很多账号本来就是系统中必须要的,我们可以简称他为系统账号, ...
- iOS 全屏布局
edgesForExtendedLayout属性用于替代wantsFullScreenLayout,控制页面显示的范围,默认值是UIRectEdgeAll automaticallyAdjustsSc ...
- 311. Sparse Matrix Multiplication
题目: Given two sparse matrices A and B, return the result of AB. You may assume that A's column numbe ...
- Scala模式匹配和类型系统
1.模式匹配比java中的switch case强大很多,除了值,类型,集合等进行匹配,最常见的Case class进行匹配,Master.scala有大量的模式匹配. Case "_&qu ...
- powerdesigner jdbc 连接 oracle
实验环境: powerdesigner 15 oracle 11g jdk1.6.0_43 提示:jdk必须选择32位,64位会报 "Could not Initialize JavaVM ...
- eclipse运行mapreduce报错Permission denied
今天用在eclipse-hadoop平台上运行map reduce(word count)出错了,错误信息为 org.apache.hadoop.security.AccessControlExcep ...