Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Error: No identifier specified for entity

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.13k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: