I was working with spring 4 integration with hibernate 4 and encountered and error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ...CustomConfiguration: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: ...
I was trying to load a table user with primary key Id. While I marked the id as @Id i was still getting the above error.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public int getId() {
return this.id;
}
Solution:
Always add
import javax.persistence.Id;
Not to use :
import org.springframework.data.annotation.Id;
0 Comment(s)