String sql = "DELETE a FROM FacilityClient a";
Query query = manager.createQuery(sql);
query.executeUpdate();
for (int i = 0; i < list.size(); i++) {
FacilityClientDetails d = list.get(i);
FacilityClient entity = new FacilityClient();
entity.setSnils(d.snils);
entity.setPolisSN(d.polisSN);
entity.setSurname(d.surnameId == 0 ? null : findEntity(Surname.class, d.surnameId));
entity.setName(d.nameId == 0 ? null : findEntity(Name.class, d.nameId));
entity.setPathronymic(d.pathronId == 0 ? null : findEntity(Patronymic.class, d.pathronId));
entity.setSex(findEntity(Sex.class, d.sexId));
entity.setBorn(d.bornDate);
entity.setDocumentType(d.docTypeId == 0 ? null : findEntity(ClientDocumentType.class, d.docTypeId));
entity.setDocumentSN(d.docSN);
entity.setAddress(d.address);
entity.setBuilding(d.building);
entity.setCorpus(d.corpus);
entity.setFlat(d.flat);
entity.setOkatoReg(d.okatoReg);
entity.setFlagNSU(d.flagNSU);
entity.setNsuBegin(d.nsuBegin);
entity.setNsuEnd(d.nsuEnd);
entity.setExcemption1(d.exemp1Id == 0 ? null : findEntity(Excemption.class, d.exemp1Id));
entity.setExcemption2(d.exemp2Id == 0 ? null : findEntity(Excemption.class, d.exemp2Id));
entity.setRegBegin(d.regBegin);
entity.setRegEnd(d.regEnd);
entity.setuType(d.uType);
entity.setdType(d.dType);
entity.setcReg(d.c_reg);
saveEntity(entity);
}
sql = "DELETE a FROM FacilityDocument a";
query = manager.createQuery(sql);
query.executeUpdate();
for (int i = 0; i < docList.size(); i++) {
FacilityDocumentDetails d = docList.get(i);
FacilityDocument entity = new FacilityDocument();
entity.setSnils(d.snils);
entity.setExcemption(d.exempId == 0 ? null : findEntity(Excemption.class, d.exempId));
entity.setDocumentName(d.docType);
entity.setDocumentSN(d.docSN);
entity.setGspBegin(d.gspBegin);
entity.setGspEnd(d.gspEnd);
saveEntity(entity);
}
}