연관관계 매핑
-
[JPA] Primary Key가 아닌 필드를 참조하는 Foreign Key 를 만들때개발 2021. 12. 12. 17:27
Primary Key가 아닌 필드를 참조하는 Foreign Key 를 만들때 @JoinColumn(referencedColumnName = [참조하는 필드 이름]) 오류 상황 Stock 이라는 테이블과 DailyStock 이라는 데이터 필드의 일대다(1:N) 매칭 시 일어난 문제이다. Price 는 Stock 의 tickerSymbol 이라는 필드를 참조하고 있다. Price @Entity public class Price { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "price_id") private Long priceId; @ManyToOne @JoinColumn(name = "ticker_symbol") priva..