因为我的hibernate映射表没有主键所以报这个错。

解决方案是:

  1、创建一个主键

  2、hibernate处理无主键的表的映射问题,其实很简单,就是把一条记录看成一个主键,即组合主键<composite-id>。

  注意:使用虚拟联合主键的话,实体类必须实现序列化接口:

  org.hibernate.MappingException: Composite-id class must implement Serializable: cn.itcast.domain.Counter

  1. < hibernate-mapping >
  2. < class name = "com.cqgl.po.SaI18nLimitRulesPO" table = "SA_I18N_LIMIT_RULES" >
  3. < composite-id >
  4. < key-property name = "aircompanyCode" type = "java.lang.String" >
  5. < column name = "AIRCOMPANY_CODE" />
  6. </ key-property >
  7.  
  8. < key-property name = "aircompanyName" type = "java.lang.String" >
  9. < column name = "AIRCOMPANY_NAME" />
  10. </ key-property >
  11.  
  12. ......
  13.  
  14. </ composite-id >
  15. </ class >
  16. </ hibernate-mapping >

org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter的更多相关文章

  1. JPA error org.hibernate.AnnotationException: No identifier specified for entity

    错误:org.hibernate.AnnotationException: No identifier specified for entity 原因:JPA所使用的Entity需要标注@Id,在引用 ...

  2. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  3. Springboot- Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    错误与异常: Caused by: org.hibernate.AnnotationException: No identifier specified for entity: 原因:引用了不对的包, ...

  4. org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity.User错误

    最近在公司带人,他们问我的问题在这里也顺便总结下. 此项目为SpringDataJpa项目. 出现的错误如下: Caused by: org.hibernate.AnnotationException ...

  5. org.hibernate.AnnotationException: No identifier specified for entity:

    使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity的异常, ...

  6. org.hibernate.AnnotationException: No identifier specified for entity 错误解决

    主键对应的属性上加上@Id注解,对应javax.persistence.Id @Id private Long id;

  7. 解决Entity 实体类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误

    启动报错如下图所示: 解决方案: 查看网上的资料,大部分都说在实体类中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查了很久,发现是我 ...

  8. Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误

    查看网上的资料,应该是报错的实体类com.example.domain.p.User中没有添加加主键的注解@Id,这个是必须的.但是我的实体类中明明已经添加了@Id,为什么还会报这个错误呢? 后来检查 ...

  9. 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 ...

随机推荐

  1. 历代诗词咏宁夏注释3----蔡升元:<题大清渠>

    题大清渠 蔡升元 为怜□□□□□,□□□□□□□. □□□□沙碛里,凿开峡口贺兰旁. 支分九堡通沟浍,鼎峙三渠并汉唐. 作吏尽如君任事,不难到处乐丰穰. 两渠中划大清渠,畚筑无劳民力纾.[1] 心画万 ...

  2. C#中使用MySqlCommand执行插入语句后获取该数据主键id值的方法

    .net中要连接mysql数据库,需要引用MySql.Data.dll文件,这文件在mysql官网上有下载. 接着通过MySqlCommand执行插入语句后想要获取该数据主键id值的方法如下: lon ...

  3. C# 枚举类型操作

    //定义一个枚举 public enum Colors { Red, Green, Blue, Yellow }; //根据key找value string name = Enum.GetName(t ...

  4. C# 工厂

    /// <summary> /// 创造实例 /// </summary> /// <typeparam name="T">类型</typ ...

  5. PHP:错误 Deprecated: Function split() is deprecated in ... 解决办法

    PHP:错误 Deprecated: Function split() is deprecated in ... 解决办法 PHP5.3 split() 不建议使用的原因:PHP 5.3.0 之后的r ...

  6. (转载)怎么写tab?

    演示地址:http://www.adanghome.com/js_demo/3/ =========================================================== ...

  7. MyBatis学习总结_04_解决字段名与实体类属性名不相同的冲突

    一.准备演示需要使用的表和数据 CREATE TABLE orders( order_id INT PRIMARY KEY AUTO_INCREMENT, order_no VARCHAR(20), ...

  8. MyBatis学习总结_02_使用MyBatis对表执行CRUD操作

    一.使用MyBatis对表执行CRUD操作——基于XML的实现 1.定义sql映射xml文件 userMapper.xml文件的内容如下: 1 <?xml version="1.0&q ...

  9. CentOS7安装配置Apache HTTP Server

    RPM安装httpd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 # yum -yinstall http ...

  10. android 使用静态变量传递数据

    使用静态变量传递数据之通用方式. 测试应用:当前页面点击button传递数据到一个新的页面显示在textview中. 首先在,mainActivity.xml文件中加入一个button按钮 <B ...