Spring JPA异常-找到对集合的共享引用

时间:2019-06-10 06:15:35

标签: java mysql hibernate spring-boot spring-data-jpa

异常

org.springframework.orm.jpa.JpaSystemException: Found shared references to a collection: lk.pwc.projects.rdd.rims.entitymanagement.domain.common.Land.deedList; 
nested exception is org.hibernate.HibernateException: Found shared references to a collection: lk.pwc.projects.rdd.rims.entitymanagement.domain.common.Land.deedList

引起问题的代码段

    @ElementCollection(fetch = FetchType.LAZY)
    @CollectionTable(name = "land_application_upload_deed", joinColumns = @JoinColumn(name = "land_application_id"))
    private Set<LandDeed> deedList;

在“映射上方”引发错误

1 个答案:

答案 0 :(得分:2)

每当您重新初始化collection属性时,都会发生此事情。在您的情况下,它是“ deedList”。无需重新初始化它,只需清除它并在其中添加新元素即可。