Command command;
try {
command = em.getReference(Command.class, id);
command.getName();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The command with id " + id + " no longer exists.", enfe);
}
Collection<Usergroup> usergroupCollection = command.getUsergroupCollection();
for (Usergroup usergroupCollectionUsergroup : usergroupCollection) {
usergroupCollectionUsergroup.getCommandCollection().remove(command);
usergroupCollectionUsergroup = em.merge(usergroupCollectionUsergroup);