private ModuleEntity lookupModuleFromCode(String modCode) {
        ModuleEntity m = new ModuleEntity();
        try {
            Query q = em.createQuery("SELECT m FROM Module m WHERE m.moduleCode LIKE :modCode");
            q.setParameter("modCode", modCode);
            m = (ModuleEntity) q.getSingleResult();
        } catch (EntityNotFoundException e) {
            System.out.println("ERROR: Module not found. " + e.getMessage());
            m = null;
        } catch (NoResultException e) {
            System.out.println("ERROR: Module does not exist. " + e.getMessage());
            m = null;
        }
        return m;
    }