if (id instanceof Long)
{
try
{
Session session = getCurrentSession();
HibernateRoleImpl role = (HibernateRoleImpl)session.load(HibernateRoleImpl.class, (Long)id);
Iterator users = role.getUsers().iterator();
while (users.hasNext())
{
HibernateUserImpl user = (HibernateUserImpl)users.next();
user.getRoles().remove(role);
}
String name = role.getName();
session.delete(role);
session.flush();
fireRoleDestroyedEvent(id, name);