private LecturerEntity lookupLecturer(String staffNum) {
        LecturerEntity l = new LecturerEntity();
        try {
            Query q = em.createQuery("SELECT l FROM Lecturer AS l WHERE l.staffNumber=:staffNumber");
            q.setParameter("staffNumber", staffNum);
            l = (LecturerEntity) q.getSingleResult();
        } catch (EntityNotFoundException e) {
            System.out.println("ERROR: Lecturer not found. " + e.getMessage());
            em.remove(l);
            return null;
        } catch (NoResultException e) {
            System.out.println("ERROR: Lecturer does not exist. " + e.getMessage());
            em.remove(l);
            return null;
        }
        return l;
    }