org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:

Yunny.Log ·2022년 7월 15일
0

Debugging

목록 보기
33/69
post-thumbnail
post-custom-banner

발생한 에러

org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:

이전

        this.releaseOrganization =
                req.getReleaseOrganizationId().size() == 0 ?
                        null :
                        (req.getReleaseOrganizationId().stream().map(
                                i -> releaseOrganizationRepository
                                .findById(i).orElseThrow
                                (CrEffectNotFoundException::new)
                        ).collect(toList())) //입력으로 받아온 co effect 값
                                .stream().map(
                                        //다대다 관계를 만드는 구간
                                        ro -> new ReleaseOrgRelease(
                                                ro,
                                                this
                                        )
                                ).collect(toList());

이후

this.releaseOrganization.clear();

        Set<ReleaseOrgRelease> releaseOrganizations =
                req.getReleaseOrganizationId().size() == 0 ?
                        null :
 (req.getReleaseOrganizationId().stream().map(
                                i -> 
                                releaseOrganizationRepository.findById(i)
                              .orElseThrow(ReleaseOrganizationNotFoundException::new)
                        ).collect(toList())) //입력으로 받아온 co effect 값
                                .stream().map(
                                        //다대다 관계를 만드는 구간
                                        ro ->
                                                new ReleaseOrgRelease(
                                                        ro,
                                                        this
                                                )

                                ).collect(Collectors.toSet());

        this.releaseOrganization.addAll(releaseOrganizations);

출처

https://blog.leocat.kr/notes/2016/04/26/hibernate-no-longer-reference

post-custom-banner

0개의 댓글