본문 바로가기
MySql

MySQL Table 'DBNAME.hibernate_sequence' doesn't exist

by 베이스 공부 2020. 10. 20.
반응형

스프링 데이터 / JPA를 사용하는 Spring Boot 2.0.1.RELEASE 애플리케이션이 있습니다.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

하지만 Amazon Aurora DB에서 업데이트를 수행 할 때 다음 오류가 발생했습니다.

2018-04-13 09:20 [pool-1-thread-1] 오류 o.h.id.enhanced.TableStructure.execute (148)-hi 값을 읽을 수 없습니다. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : 'elbar.hibernate_sequence'테이블이 sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)에 존재하지 않습니다.

저장하려는 엔티티에이 항목이 있습니다.

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

ID를 가져 오기 위해 DB의 단점도 피하고 싶습니다.

 

해결 방법

 

GenerationType.AUTO 세대를 사용하면 hibernate는 기본 hibernate_sequence 테이블을 찾으므로 다음과 같이 생성을 IDENTITY 로 변경합니다.

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

 

참조 페이지 https://stackoverflow.com/questions/49813666

 

 

반응형

댓글