org.hibernate.AnnotationException: No identifier specified for entity
2017-01-09 15:25
459 查看
转载自:http://blog.sina.com.cn/s/blog_529aacbd0100z8u2.html
使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity异常。可是entity类的注释没有问题,唯一的不正常的地方是这张表比较特殊没有主键,好像在使用hibernate的映射表的时候entity类是必须要主键的,否则就会报出这个异常。解决办法自然是add一个主键进去,这里主要是对实体类的注释,应该做添加
使用hibernate的e-r映射pojo类的时候遇到org.hibernate.AnnotationException: No identifier specified for entity异常。可是entity类的注释没有问题,唯一的不正常的地方是这张表比较特殊没有主键,好像在使用hibernate的映射表的时候entity类是必须要主键的,否则就会报出这个异常。解决办法自然是add一个主键进去,这里主要是对实体类的注释,应该做添加
@Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "id", nullable = false) private int id;
相关文章推荐
- org.hibernate.AnnotationException: No identifier specified for entity
- Entity 类中加了@Id 注解后仍然出现org.hibernate.AnnotationException: No identifier specified for entity 错误
- 解决:org.hibernate.annotationexception no identifier specified for entity
- org.hibernate.annotationexception no identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity: entity.Student
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity
- Caused by: org.hibernate.AnnotationException: No identifier specified for entity
- nested exception is org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.liuyanzhao.b
- Hinernate:org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity: com.bjsxt.hibernate.Teacher
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity
- org.hibernate.AnnotationException: No identifier specified for entity