[Hibernate][MySQL] org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " alter table Reply add constraint FKr5xsgtav636xcqpjh0j81wb2n foreign key ('boardId') references Board (id)" via JDBC Statement

2022. 3. 5. 06:49· Debug
728x90
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "
    alter table Reply 
       add constraint FKr5xsgtav636xcqpjh0j81wb2n 
       foreign key ('boardId') 
       references Board (id)" via JDBC Statement
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''userId') 
       references User (id)' at line 3​

 

 

 

 

 

연관관계 설정하는 부분에서 자꾸 에러가남

 

@JoinColumn의 name = 부분의 " 'userId' " 이 부분을

name = "userId"로 바꿔줘야함 이건 컬럼의 데이터 값이 아니라 필드값이라서 ' '를 붙이면 안됨

 

' '를 붙여야하는 어노테이션은 

ex) @ColumnDefault("'user'")

 

 

 

 

 

 

blog DB의 reply Table에 foreign Key로 boardId와 userId가 제대로 설정돼있음

저작자표시 (새창열림)

'Debug' 카테고리의 다른 글

삭제하기 기능은 @PostMapping이 아니라 @DeleteMapping을 애노테이션으로 붙여주어야 한다  (0) 2022.03.14
"org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value : com.cos.blog.model.User.email; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient ..  (0) 2022.03.14
[Hibernate][MySQL] Unsupported property type [java.security.Timestamp] for @CreationTimestamp or @UpdateTimestamp generator annotation  (0) 2022.03.04
[Maven] pom.xml에 pring-boot-starter-data-jpa를 추가해줘도 @Entity를 사용할 수 없는 경우 (import javax.persistence.Entity가 안되는 경우)  (0) 2022.03.04
[SpringBoot] ***************************APPLICATION FAILED TO START***************************Description:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a sui..  (0) 2022.02.28
'Debug' 카테고리의 다른 글
  • 삭제하기 기능은 @PostMapping이 아니라 @DeleteMapping을 애노테이션으로 붙여주어야 한다
  • "org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value : com.cos.blog.model.User.email; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient ..
  • [Hibernate][MySQL] Unsupported property type [java.security.Timestamp] for @CreationTimestamp or @UpdateTimestamp generator annotation
  • [Maven] pom.xml에 pring-boot-starter-data-jpa를 추가해줘도 @Entity를 사용할 수 없는 경우 (import javax.persistence.Entity가 안되는 경우)
배게
배게
백엔드배게 님의 블로그입니다.
배게
백엔드
배게
전체
오늘
어제
  • 분류 전체보기 (430)
    • 알고리즘 풀이 (338)
      • 백준 (167)
      • Codility (22)
      • 프로그래머스 (123)
      • LeetCode (2)
      • CodeForces (9)
      • SWEA (15)
    • 백엔드 (11)
    • Coding existing for (3)
    • 무지성 메모 (40)
    • Debug (30)
    • 자바 (8)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • 카톡 내보내기한 파일 정렬
  • 카카오톡 txt파일 정렬
  • 카톡
  • hibernate
  • MYSQL
  • 카카오톡

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.1
배게
[Hibernate][MySQL] org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " alter table Reply add constraint FKr5xsgtav636xcqpjh0j81wb2n foreign key ('boardId') references Board (id)" via JDBC Statement
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.