log.info("creating query");
Query query = manager.createQuery("SELECT r FROM RoleImpl AS r WHERE r.name =:name");
log.info("setting parameter name to " + name);
query.setParameter("name", name);
log.info("query.getsingleresult()");
Role role = null;
try {
log.info("In catch block to retrieve user");
role = (Role)query.getSingleResult();
} catch (NoResultException e) {
// Catch the runtime exception and set user to null
log.info("Role doesn't exist so setting to null");
role = null;
}
log.info("testing for role == null");
if( role == null ) throw new RoleNotFoundException();
log.info("Role name = " + role.getName());
return role;
}