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

今天在测试 jpa 读取数据库时出现这错误,指示没有实体标识符

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

根据Hinbernate的规范,一定要为实体类添加唯一的标识符,即主键id。在私有变量或set方法之上添加注解即可。
@Id 
@GeneratedValue
private Integer categoryId;

猜你喜欢

转载自blog.csdn.net/qq_23483671/article/details/79056174