2
我有以下兩個實體:問題「刪除的對象將被重新保存通過級聯」
1-新政
@OneToMany(cascade=CascadeType.ALL,mappedBy = "deal", fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private List<DealCheckList> dealCheckList;
2- DealCheckList
@JoinColumn(name = "DEAL_ID", referencedColumnName = "DEAL_ID", insertable = false, updatable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Deal deal;
使用
012刪除子對象,即DealCheckList時.......
.......
transaction = session.beginTransaction();
Deal deal = (Deal) session.createCriteria(Deal.class)
.add(Restrictions.eq("dealId", dealId)).uniqueResult();
for(DealCheckList checklist : deal.getDealCheckList()){
session.delete(checklist);
}
transaction.commit();
我提示以下錯誤:
Caused by: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations):
請幫助。
同意。錯誤消息不會比那個更清晰:) +1 –