删除孤儿数据

阅读更多

//获得set,清空

umpActivity.getUmpActivityTypeSet().clear();

//设置新值,会将新的数据加进去,原来的全部会被删掉,因为 @Cascade(org.hibernate.annotations.CascadeType.ALL)
umpActivity.getUmpActivityTypeSet().addAll(newUmpActivityTypeSet);

 

 

@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "umpActivity", fetch = FetchType.EAGER)
 @Cascade(org.hibernate.annotations.CascadeType.ALL)
 @JoinColumn(name = "activity_id")
 @OrderBy("umpType")
 public Set getUmpActivityTypeSet() {
  return umpActivityTypeSet;
 }

你可能感兴趣的:(cascade)