annotationexception专题

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

使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity异常。可是entity类的注释没有问题,唯一的不正常的地方是这张表比较特殊没有主键,好像在使用hibernate的映射表的时候entity类是必须要主键的,否则就会报出这个异常。 解决办法自然是add一个主键

spring data jpa项目启动报错,Caused by: org.hibernate.AnnotationException: No identifier specified for enti

解决方法:在实体类上添加@MappedSuperclass注解。 因为我的实体类都有id字段,所以我抽象出来一个IdEntity基类,之后忘了给它添加@MappedSuperclass注解;如果你的实体类没有父类IdEnity,只在实体类的id字段添加如下代码,@column不是必须的。

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

Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.ljs.Demo_03_ManyToMany.entity 这是导入错类了 重新导入正确的类即可。