티스토리 뷰
카테고리 없음
JPA Error: contains physical column name [xxx] referred to by multiple logical column names 이란 에러 발생할 경우 FK 중복에러
패스트코드블로그 2020. 5. 27. 17:08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity(name="schedule")
public class Schedule {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long scheNo;
@NotNull
@Column(length = 10) private String stadiumId;
@NotNull @Column(length = 10) private String gubun;
@Column(length = 10) private String hometeamId;
@Column(length = 10) private String awayteamId;
@Column(length = 10) private String homeScore;
@Column(length = 10) private String awayScore;
@Builder
public Schedule(String stadiumId, String gubun, String hometeamId, String awayteamId,
String homeScore, String awayScore){
this.stadiumId=stadiumId;
this.gubun=gubun;
this.hometeamId=hometeamId;
this.awayteamId=awayteamId;
this.homeScore=homeScore;
this.awayScore=awayScore;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "stadium_id") @NotNull
private Stadium stadium;
}
|
cs |
에서 12번째 라인에 보면 statdiumId 를 준 것이 있다. 이것은 FK 키를 그대로 추가한 것이다.
ERD 에서는 있지만 Entity 클래스에는 이것을 빼야한다.
왜냐하면 29번째 코드에서 설정으로 자동으로 추가되기 때문이고, 이유로 중복된 컬럼 에러가 발생한 것이다.
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- SQLAlchemy
- JPA
- SpringBoot
- Java
- COLAB
- Git
- database
- terms
- maven
- vscode
- React
- Oracle
- KAFKA
- JUnit
- mariadb
- Mongo
- springMVC
- Eclipse
- Python
- jQuery
- FLASK
- tensorflow
- AWS
- Mlearn
- nodejs
- docker
- Algorithm
- intellij
- Django
- ERD
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함