我有以下两个实体:
1- 交易
@OneToMany(cascade=CascadeType.ALL,mappedBy = "deal", fetch = FetchType.EAGER)
@Fetch( FetchMode.SELECT)
private List<DealCheckList> dealCheckList;
2- 交易清单
@JoinColumn(name = "DEAL_ID", referencedColumnName = "DEAL_ID", insertable = false, updatable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Deal deal;
删除子对象时,即 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):
请帮忙。