String sql = "select e.id, e.client.surname, e.client.name, e.client.pathronymic, e.client.born from Emc e";
Query query = manager.createQuery(sql);
@SuppressWarnings("unchecked")
List<Object[]> list = query.getResultList();
for (Object[] line: list) {
ClientUniq cu = new ClientUniq();
Integer emcID = (Integer) line[0];
Surname surname = (Surname) line[1];
Name name = (Name) line[2];
Patronymic pathronymic = (Patronymic) line[3];
cu.surnameID = surname == null ? 0 : surname.getId();
cu.nameID = name == null ? 0 : name.getId();
cu.pathronID = pathronymic == null ? 0 : pathronymic.getId();
cu.dateBorn = (Date) line[4];
mapEmc.put(cu, emcID);
}
for (LNumberChunk c: lNumberChunkList) {
ClientUniq cu = new ClientUniq();
cu.surnameID = c.famID;
cu.nameID = c.nameID;
cu.pathronID = c.patronID;
cu.dateBorn = c.born;
Integer emcID = mapEmc.get(cu);