2023-10-26T18:19:24.602+09:00 ERROR 26372 --- [ main]
j.LocalContainerEntityManagerFactoryBean :
Failed to initialize JPA EntityManagerFactory:
[PersistenceUnit: default]
Unable to build Hibernate SessionFactory;
nested exception is org.hibernate.MappingException:
Could not instantiate id generator [entity-name=jpabook.jpashop.Member]
인프런의 김영한 강사님 JPA 실전 수업을 듣는데 이런 에러가 났어요..
강사님이랑 똑같이 쳤는데!! 흥
엔티티 생성할 때 생긴 문제니까 회원 엔티티였던 Member 클래스를 수정했습니다
- 기존 코드
@Entity
@Getter @Setter
public class Member {
@Id
@GeneratedValue
private Long id;
private String username;
}
- 수정한 코드
@Entity
@Getter @Setter
public class Member {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String username;
}
⚡️Hibernate 기본 ID 생성 전략 : 'GenerationType.AUTO' → 데이터베이스 벤더에 따라 자동으로 ID 생성 전략이 선택됨
⚡️'GenerationType.IDENTITY' → Hibernate 에게 명시적으로 ID 필드를 데이터베이스의 IDENTITY 컬럼으로 사용하도록 알려주는 것 (데이터베이스에 자동으로 생성된 ID 를 사용하도록 지시)
⚡️🚨⚡️
(っ´ω`)っ 성공이다...
'ERROR' 카테고리의 다른 글
[Git/Github] error setting certificate file (0) | 2024.01.19 |
---|---|
[Spring] Exception processing template (0) | 2023.11.26 |
[Spring] CommandAcceptanceException : Error executing DDL (2) | 2023.11.15 |
[WinError 10013] 액세스 권한에 의해 숨겨진 소켓에 액세스를 시도했습니다. (0) | 2023.03.30 |
[Linux] 다른 IP 로 파일 전송하기 (0) | 2023.03.30 |