@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@EqualsAndHashCode
@IdClass(ClassifyActivateId.class)
public class ClassifyActivate {
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "classification_id")
private Classification classification;
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "~_id")
private ~ ~
}
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "classification1_id")
private Classification1 classification1;
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "classification2_id")
private Classification2 classification2;
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "classification3_id")
private Classification3 classification3;
이와 같이 안에 세개의 객체를 가지고 있다 , 따라서 JoinColoimn을 얘에 맞게 해주어야 한다. 총 세개의 조인컬럼을 해줘야 하는 것!
따라서 위의 필드에 세개의 조인컬럼을 해주며 에러를 해결했다.
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@EqualsAndHashCode
@IdClass(ClassifyActivateId.class)
public class ClassifyActivate {
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "c1_id") //조인 컬럼 추가
@JoinColumn(name = "c2_id") //조인 컬럼 추가
@JoinColumn(name = "c3_id") //조인 컬럼 추가
private Classification classification;
@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "~_id")
private ~ ~
}
해결 참조
스택오버플로우 : https://stackoverflow.com/questions/27215607/annotationexception-a-foreign-key-refering-has-the-wrong-number-of-column-shou