Caused by: java.sql.SQLException: Referencing column 'fk_id' and referenced column 'id' in foreign key constraint 'FK어쩌구' are incompatible.

Exception

목록 보기
10/16

부모 엔티티 ⬇️

public class Product {
  ...
  
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "counselor_id", nullable = false,
      columnDefinition = "BIGINT UNSIGNED COMMENT '수업 담당 전문가 PK'")
  private Counselor counselor;

  ...
  
}

자식 엔티티 ⬇️

public class Counselor {

  @Id
  @Column(columnDefinition = "BIGINT COMMENT '전문가 PK'")
  private BigInteger id;
  
  ....
}

부모 엔티티에는 UNSIGNED 옵션을 주었는데 자식 테이블 PK에는 주지 않아서 발생했다!

mysql에서UNSIGNED는 음수로 저장되면 안되는 필드에 걸어주는 옵션입니다.

profile
야호 약간 헌 개발자....

0개의 댓글