@SuppressWarnings("unchecked") public List<SectionCFODto> getByCfoId(Long cfoId) { List<SectionCFODto> result = new ArrayList<SectionCFODto>(); Query sectionCfoQuery = em.createQuery( "select sectionCfo from SectionCFO sectionCfo where sectionCfo.cfo.id = :cfoId"); sectionCfoQuery.setParameter("cfoId", cfoId); List<SectionCFO> resultList = sectionCfoQuery.getResultList(); for (SectionCFO sectionCfo : resultList) { // CFO cfo = sectionCfo.getCfo(); Section section = sectionCfo.getSection(); CfoDto cfoDto = new CfoDto(sectionCfo.getCfo().getId(), sectionCfo.getCfo().getName()); SectionDto sectionDto = new SectionDto(section.getId(), section.getName(), section.getCode()); SectionCFODto dto = new SectionCFODto(cfoDto, sectionDto, sectionCfo.getStartDate(), sectionCfo.getEndDate()); result.add(dto); } return result; }
public SectionCFODto toDto(SectionCFO sectionCfo, boolean full) { if (sectionCfo == null) return null; SectionCFODto dto = new SectionCFODto( sectionCfo.getId(), sectionDao.toDto(sectionCfo.getSection()), sectionCfo.getStartDate(), sectionCfo.getEndDate()); return dto; }