해결된 질문
24.03.23 20:57 작성
·
428
0
영화 예매 관련 Entity를 작성 후 DB확인차 실행했는데 다른 Entity는 테이블이 잘 만들어진 것을 확인할 수 있었지만 이상하게 Seat Entity만 테이블이 만들어지지 않았습니다.
WARN 3508 --- [Movie Ticketing] [ restartedMain] o.m.jdbc.message.server.ErrorPacket : Error: 1146-42S02: Table 'ticketing.seat' doesn't exist
WARN 3508 --- [Movie Ticketing] [ restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "
alter table seat
add constraint FKgik5885qsff01sxe7v3kqjrhx
foreign key (theater_id)
references theater (theater_id)" via JDBC [(conn=216) Table 'ticketing.seat' doesn't exist]
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
alter table seat
add constraint FKgik5885qsff01sxe7v3kqjrhx
foreign key (theater_id)
references theater (theater_id)" via JDBC [(conn=216) Table 'ticketing.seat' doesn't exist]
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:94) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.Helper.applySqlString(Helper.java:233) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.Helper.applySqlStrings(Helper.java:217) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createForeignKeys(SchemaCreatorImpl.java:303) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:250) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:172) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:142) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:118) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:256) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.lambda$process$5(SchemaManagementToolCoordinator.java:145) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]
application.yml은ddl-auto.create
입니다.
대소문자 구분이 문제인가 싶어 @Table(name = "seat")도 추가하고 lower_case_table_names = 1
인 것도 확인했는데 똑같이 에러가 발생하더라구요
하루종일 찾아봐도 이유를 잘 모르겠습니다 왜그런걸까요 ㅠㅠㅠ
Seat Entity 코드는 아래와 같습니다.
@Entity
@Table(name = "seat")
class Seat {
val row : String? = null
val column : Int? = null
//좌석 선택
@Enumerated(EnumType.STRING)
val selectStatus : SelectStatus? = null // POSSIBLE, IMPOSSIBLE
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "theater_id")
val theater : Theater? = null
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "seat_id")
val id : Long = 0L
}
답변 1
1
2024. 03. 23. 22:09
자답입니다. 방금 해결하였는데
데이터베이스의 키워드나 예약어를 엔티티 클래스에 사용해서였습니다.
application.yml에 아래 내용을 추가하면 정상작동하네요.
jpa:
properties:
hibernate:
globally_quoted_identifiers: true