@Entity
public class Report extends Model {
public Date date;
public double availability;
@ElementCollection
@Cascade(value={CascadeType.ALL})
public Map<FaultCategory, Integer> categories;
}
在我的工作之一,我有以下代碼:如何級聯刪除作爲jpa實體一部分的集合?
int n = MonthlyReport.delete("date = ?", date);
這始終無法刪除,錯誤如下實體:
The DELETE statement conflicted with the REFERENCE constraint "FK966F0D9A66DB1E54". The conflict occurred in database "TFADB", table "dbo.MonthlyReport_categories", column 'MonthlyReport_id'.
如何指定映射所以當報告被刪除時,類別集合中的元素會刪除嗎?
JPA不支持對元素集合進行級聯刪除(另請參見[這裏](http://stackoverflow.com/q/3903202/741249)) – THelper