首先看两者的关系为也可以参照文件
在sub文件中有:
private List<AgreementFee> agreFee = new ArrayList<AgreementFee>();
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,mappedBy = "agreementSub")
public List<AgreementFee> getAgreFee() {
return agreFee;
}
public void setAgreFee(List<AgreementFee> agreFee) {
this.agreFee = agreFee;
}
在fee文件中有:
如何解除关系,删除多方呢
/**
* 删除子列表下面的费用
* @author chensy
* @date 2013-11-13
* @param subId
*/
public void delSubMes(String subId){
//获得子列表
AgreementSub agreementSub = agreementSubDao.queryBySubId(subId);
//获得费用
List<AgreementFee> list = agreementSub.getAgreFee();
List<String> ids = new ArrayList<String>();
for (AgreementFee agreementFee : list) {
ids.add(agreementFee.getId());
}
if(ids!=null && ids.size() > 0){
agreementFeeDao.delFeeMes(ids);
}
}
fee
/**
* 删除费用
* @author chensy
* @date 2013-11-14
* @param ids
*/
public void delFeeMes(List<String> ids){
session = getSession();
AgreementFee agreementFee = null;
for (String string : ids) {
agreementFee = this.queryAgreementFee(string);
agreementFee.getAgreementSub().getAgreFee().remove(agreementFee);
agreementFee.setAgreementSub(null);
}
session.delete(agreementFee);
}