public Integer saveAssignedReports(Integer formId, FormReportVoCollection formRepColl) throws StaleObjectException, ForeignKeyViolationException { DomainFactory factory = getDomainFactory(); factory.delete("from FormReportBo fr where fr.form.id = " + formId); for (int i = 0; i < formRepColl.size(); i++) { FormReportVo vo = formRepColl.get(i); FormReportBo bo = new FormReportBo(); ReportBo doRep = (ReportBo)factory.getDomainObject(ReportBo.class, vo.getReport().getID_ReportBo()); AppForm doForm = (AppForm)factory.getDomainObject(AppForm.class, formId); bo.setForm(doForm); bo.setReport(doRep); factory.save(bo); } return new Integer(formRepColl.size()); }