@Override
    public boolean changePassword(String matricNum, String newPassword) {
        Query q = em.createQuery("SELECT s FROM Student s WHERE s.matricNumber = :matric");
        q.setParameter("matric", matricNum);
        studentEntity = (StudentEntity) q.getResultList().get(0);
        String hashedPassword = null;
        try {
            hashedPassword = encode(newPassword);
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(MRSBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (hashedPassword == null) {
            System.out.println("Error: Password to be updated cannot be empty!");
            return false;
        }
        studentEntity.setPassword(hashedPassword);
        em.merge(studentEntity);
        return true;
    }