NadezhdaGeorgieva

8.GetEmployeeWithProject

Jul 1st, 2021
1,106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void exEightGetEmployeeWithProject() throws IOException {
  2.         System.out.println("Please enter employee id:");
  3.         long employeeId = Integer.parseInt(reader.readLine());
  4.         Employee employee = entityManager.find(Employee.class, employeeId);
  5.  
  6.         System.out.printf("%s %s - %s%n",
  7.                 employee.getFirstName(),
  8.                 employee.getLastName(),
  9.                 employee.getJobTitle());
  10.  
  11.         employee.getProjects().stream()
  12.                 .map(Project::getName)
  13.                 .sorted()
  14.                 .forEach(project -> System.out.printf("\t%s%n", project));
  15.     }
RAW Paste Data