0

I need help, I made an experiment to get an idea about JPA and I got this error.

Knowing that I have defined all of them in the application.properties file.

I use MySQL Workbench version 8

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=171203Hf
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop

Person Entity

import org.springframework.data.annotation.Id;
import javax.persistence.*;

@Entity
@Table(name = "Person")
public class Person {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    @Column
    private String name;

    public Person(){

    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


}

I tried to do an experiment to understand how JPA works, but it always shows this error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: in.hashem.restdemoweb.model.Person

Jens
  • 67,715
  • 15
  • 98
  • 113
  • Please add the complete stacktrace – Jens Jul 14 '23 at 13:11
  • 1
    Does this answer your question? [Org.Hibernate.AnnotationException: No Identifier Specified For Entity I don't have a id in my table](https://stackoverflow.com/questions/25851029/org-hibernate-annotationexception-no-identifier-specified-for-entity-i-dont-ha) – Jens Jul 14 '23 at 13:13
  • 2
    Look at https://stackoverflow.com/a/33114283/3636601 – Jens Jul 14 '23 at 13:13

0 Answers0