public boolean hasRole(Role role, User user) throws Exception {
        
        try {
            boolean itHasRole = false;
            session = HibernateUtil.getSessionFactory().openSession();
            session.beginTransaction();
            Query q = session.getNamedQuery(getNamedQueryToHasRole());
            q.setString("user", Integer.toString(user.getId()));
            q.setString("role", Integer.toString(role.getId()));
            List lt = q.list();
            session.getTransaction().commit();
            
            if (lt.size() > 0) {
                itHasRole = true;
            }
            
            return itHasRole;
        } catch (HibernateException e) {
            throw new Exception(e.getCause().getLocalizedMessage());
        } finally {
            releaseSession(session);
        }
        
    }