Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

Code Block
Caused by: java.sql.SQLSyntaxErrorException: Table 'DBNAME.hibernate_sequence' doesn't exist


원인

Entity 의 ID 생성 strategy 가 GenerationType.AUTO 일 경우 hibernate는 자동으로 기본 sequence 정보 테이블인 hibernate_sequence  을 찾지만 없어서 발생

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

...

Code Block
languagejava
@Entity
@Data
@Table(name="Customers")
@SequenceGenerator(name="my_seq_generator",
        sequenceName = "CUSTOMER_SEQUENCE"   // DB Sequence Name
        //, initialValue = 1,
        // allocationSize = 50
)
public class Customer {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Long id;




Ref