调用save()时无法删除jpa中的集合行

fcg9iug3  于 2021-07-16  发布在  Java
关注(0)|答案(0)|浏览(203)

我有下面的实体类。

Parent Entity:
---------------
public class MLW implements Serializable {
    @Id
    @Column(name = "mlwId", updatable = false, nullable = false)
    private String mlwId;

    @OneToOne(optional = false, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name="mlwId")
    private MLWJob mlwJob;

    private Date createdDate;
    private Date lastUpdatedDate;
}

public class MLWJob implements Serializable {
    @Id
    private String mlwId;
    @Column(name = "Id")

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name="mlwId")
    private List<MLWJobItem> items;
}

public class MLWJobItem implements Serializable {
    @Id
    private String itemId;

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name="itemId")
    private List<MLWJobItemExtension> mlwJobItemExtensions;
}

public class MLWJobItemExtension implements Serializable {
    @Id
    private String extnId;
    @Id
    private String itemId;
    private String name;
    private String value;
}

Repository class:
------------------
public interface MLWRepository extends JpaRepository<MLW, String> {
}

当我尝试使用上面的存储库调用save方法时,我得到了下面的异常。有人能帮我理解并解决这个问题吗?短暂性脑缺血发作
无法删除集合行:[com.cpc.wgln.entity.mlwjobitem.mlwjobitemextensions#010502101713441];嵌套异常为org.hibernate.exception.genericjdbception:无法删除集合行:[com.cpc.wgln.entity.mlwjobitem.mlwjobitemextensions#010502101713441]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题