}
List<User> users = em.createQuery("SELECT u FROM User u WHERE u.userGroup = :changedGroup", User.class)
.setParameter("changedGroup", group).getResultList();
for (User user : users) {
UserGroup newGroup = new UserGroup();
newGroup.setName(user.getUsername());
em.merge(user);
}
em.remove(em.merge(group));
}