public ManagerDTO getManager(String username) { try { Manager manager = new Manager(); List<Manager> managers = (List<Manager>) em.createNamedQuery("getAllManagers").getResultList(); for (Manager m : managers) { if (username.equals(m.getName())) { manager = m; return managerToDTO(manager); } } } catch (Exception e) { throw new EJBException(e.getMessage()); } return null; }
ManagerDTO managerToDTO(Manager manager) { return new ManagerDTO( manager.getId(), manager.getUserName(), null, manager.getName(), manager.getEmail()); }