private void populateLaboratoryFields(Laboratory laboratory) throws DaoEntityNotFoundException {
    Hour from = hourDao.getHourByValue(laboratory.getFrom().getValue());
    Hour to = hourDao.getHourByValue(laboratory.getTo().getValue());
    Professor professor = professorDao.getProfessorByPnc(laboratory.getProfessor().getPnc());
    Room room = roomDao.getRoomByName(laboratory.getRoom().getName());
    Day day = dayDao.getDayByValue(laboratory.getDay().getValue());
    Section section = sectionDao.getSectionByName(laboratory.getSection().getName());
    Group group = groupDao.getGroupByName(laboratory.getGroup().getName());
    Subgroup subgroup = subgroupDao.getSubgroupByName(laboratory.getSubgroup().getName());
    Year year = yearDao.getYearByValue(laboratory.getYear().getValue());
    Semester semester = semesterDao.getSemesterByValue(laboratory.getSemester().getValue());
    WeeklyOccurrence weeklyOccurrence =
        weeklyOccurrenceDao.getWeeklyOccurrenceByName(laboratory.getWeeklyOccurrence().getName());
    List<Student> students = studentDao.getStudents(section, year, semester, group, subgroup);

    laboratory.setFrom(from);
    laboratory.setTo(to);
    laboratory.setProfessor(professor);
    laboratory.setRoom(room);
    laboratory.setDay(day);
    laboratory.setSection(section);
    laboratory.setGroup(group);
    laboratory.setSubgroup(subgroup);
    laboratory.setYear(year);
    laboratory.setSemester(semester);
    laboratory.setWeeklyOccurrence(weeklyOccurrence);
    laboratory.setStudents(students);
  }
  @Override
  public void updateLaboratory(LaboratoryDto laboratoryDto) throws ServiceEntityNotFoundException {
    try {
      Laboratory laboratory = laboratoryDao.getLaboratoryById(laboratoryDto.getId());
      boolean studentsNeedUpdate = studentsNeedUpdate(laboratory, laboratoryDto);
      updateLaboratoryFields(laboratory, laboratoryDto);

      laboratoryDao.updateLaboratory(laboratory);

      if (studentsNeedUpdate) {
        laboratory.getStudents().clear();

        List<Student> students =
            studentDao.getStudents(
                laboratory.getSection(),
                laboratory.getYear(),
                laboratory.getSemester(),
                laboratory.getGroup(),
                laboratory.getSubgroup());
        laboratory.setStudents(students);
      }

    } catch (DaoEntityNotFoundException e) {
      LOGGER.debug("DaoEntityNotFoundException");
      throw new ServiceEntityNotFoundException(e);
    }
  }