// create a copy of the collection in order to avoid ConcurrentModificationException
// (as a consequence of iterating and modifying it at once).
Set<Role> roles = new HashSet<Role>(group.getRoles());
for (Role doomedRoleRelationship : roles) {
group.removeRole(doomedRoleRelationship);
entityManager.merge(doomedRoleRelationship);
}
// remove all resources in the group
resourceGroupManager.removeAllResourcesFromGroup(subject, groupId);