У меня есть 3 связных класса user, discount и holderOfDiscount.
У user@OneToMany(mappedBy = "user" , fetch=FetchType.EAGER , cascade = CascadeType.ALL , orphanRemoval = true)
private List holderOfDiscounts;
У discount @OneToMany(mappedBy = "discount" , fetch = FetchType.EAGER , cascade = CascadeType.ALL , orphanRemoval = true)
private List holderOfDiscounts;
У holderOfDiscount @ManyToOne(fetch = FetchType.EAGER )
@JoinColumn(name = "ID_OF_USER")
private User user;
@ManyToOne(fetch = FetchType.EAGER )
@JoinColumn(name = "ID_OF_DISCOUNT")
private Discount discount;
При удалении элемента из таблиц User или Discount выпадает ошибка deleted object would be re-saved by cascade (remove deleted object from associations): [entities.HolderOfDiscount#1]
Вопрос задан
более трёх лет назад
204 просмотра