[Debug]JPA 영속성 오류, joinColumn값(@ManyToOne)에 cascade추가
Programming/Debug

[Debug]JPA 영속성 오류, joinColumn값(@ManyToOne)에 cascade추가

 

서브 쿼리를 구성을 해서 

 

 

실행하던 도중

서브 쿼리 오류는 고쳤지만 아래와 같이 오류가 발생합니다.

 

object references an unsaved transient instance - save the transient instance before flushing : com.cos.unishop.domain.bucket.BucketProducts.product -> com.cos.unishop.domain.product.Product

 

영속성 때문에 오류가 나타난다던데, join 하는 쪽에 cascade를 설정해주면 해결이 됩니다.

 

cascade = cascadeType.All

 

 

문제없이 실행됩니다

 

 

 


Reference

 

https://www.baeldung.com/jpa-cascade-types

 

https://conservative-vector.tistory.com/entry/%EC%98%A4%EB%A5%98

 

[오류]TransientPropertyValueException: object references an unsaved transient instance

문제 이전글(Could not commit JPA transaction 오류)를 고쳤더니 이번엔 새로운 오류가 났다. 히히 코딩재밌다 히히 TransientPropertyValueException: object references an unsaved transient instance org.hi..

conservative-vector.tistory.com

 

https://velog.io/@2yeseul/JPA-save-the-transient-instance-before-flushing

 

[JPA] save the transient instance before flushing

오류 코드 개체가 저장되지 않은 일시적인 인스턴스를 참조합니다. 플러싱하기 전에 임시 인스턴스를 저장합니다. @OneToMany나 @ManyToOne 사용 시 부모 객체에 추가하는 자식 객체가 아직 db에 저장

velog.io

 

https://jihwan-study.tistory.com/55

 

Spring boot JPA CASCADE

# JPA CascadeType 종류 ## 1. 배경 - JPA 개인 프로젝트를 진행하던 중, 게시판과 파일, 댓글에서 @OneToMany - @ManyToOne의 관계에서 영속성 관리에서 문제가 발생되었으며, 영속성에서 참조된 객체를 지워

jihwan-study.tistory.com