[JPA]nested exception is org.hibernate.AnnotationException: Unknown mappedBy in ~ 오류

chic yeon·2021년 7월 1일
0

오류

[SpringApplication:837] - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaAuditingHandler': Cannot resolve reference to bean 'jpaMappingContext' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown mappedBy in: com.daema.rest.ysmin.domain.BasicInfo.appForm, referenced property unknown: com.daema.rest.ysmin.domain.AppForm.BasicInfo

원인

@OneToOne 양방향 관계에서 연관관계주인이 아님을 명시해주는
mappedBy = "" 네이밍 불일치 문제

@Getter
@Entity

@Table(name="basic_info")
public class BasicInfo {

	...중략...

    @OneToOne(mappedBy = "BasicInfo")
    private AppForm appForm;
    
}

@Getter
@Entity

@Table(name = "appform") 
public class AppForm {

	... 중략 ...

    @OneToOne
    @JoinColumn(name = "basic_info_id")
    private BasicInfo basicInfo;

해결

mappedby 네이밍을 올바르게 설정한다

@OneToOne(mappedBy = "BasicInfo") -> (mappedBy = "basicInfo")
private AppForm appForm;

@OneToOne
@JoinColumn(name = "basic_info_id")
private BasicInfo basicInfo;

profile
이제 시작하는 Back-end

0개의 댓글