Exemple #1
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User create(User user) {
    LOGGER.debug("User create(User user):" + user);
    Date now = new Date();
    user.setCreatedDate(now);
    user.setUpdatedDate(now);

    Role role = roleRepository.findOne(user.getRole().getId());
    user.setRole(role);

    LOGGER.debug("Creating a new user with information: " + user);
    return userRepository.save(user);
  }
Exemple #2
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User update(User user) throws Exception {
    LOGGER.debug("update(User user): " + user);
    user.setUpdatedDate(new Date());
    LOGGER.debug("Updating user with information: " + user);

    User userDb = userRepository.findOne(user.getId());

    if (userDb == null) {
      LOGGER.debug("No user found with id: " + user.getId());
      throw new Exception();
    }

    userRepository.save(user);
    return user;
  }