jpa 연관관계

    [JPA] object references an unsaved transient instance - save the transient instance before flushing

    JPA 연관관계 사용 중 아래와 같은 에러가 나왔다. object references an unsaved transient instance - save the transient instance before flushing 오류 이유 해당 오류가 생기는 이유는 FK 로 사용되는 컬럼값이 없는 상태에서 데이터를 넣으려다보니 생기는 에러인 것이다. 예를 들어 아래와 같은 내용이 있을 때 Member (id, name) Address (id, address1, member_id) Member에 데이터를 넣지 않고 Address 에 데이터를 넣으려고 하면 member_id 값이 없어서 에러가 발생하는 것이다. 해결 방법 해결 방법으로는 연관관계를 설정할 때 cascade 옵션을 설정해준다. cascade = Ca..