*/
@Transactional
public User saveOrUpdate(User user) {
User exist = getByUsername(user.getUsername());
if (exist != null && !StringUtils.equals(user.getId(), exist.getId())) {
throw new DuplicateException(User.class.getName(), "username", user.getUsername());
}
exist = getByEmail(user.getEmail());
if (exist != null && !StringUtils.equals(user.getId(), exist.getId())) {
throw new DuplicateException(User.class.getName(), "email", user.getEmail());
}
return entityManagerProvider.get().merge(user);
}