Пример #1
0
  @Transactional(readOnly = false, rollbackFor = Exception.class)
  @Override
  public User delete(Long id) throws Exception {
    LOGGER.debug("User delete(Long id): " + id);

    User user = userRepository.findOne(id);

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

    userRepository.delete(user);
    return user;
  }
Пример #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;
  }
Пример #3
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);
  }
Пример #4
0
 @Transactional(readOnly = true)
 @Override
 public List<User> findAllOrdered() {
   LOGGER.debug("findAllOrdered()");
   return userRepository.findAllOrdered();
 }
Пример #5
0
 @Transactional(readOnly = true)
 @Override
 public User findById(Long id) {
   LOGGER.debug("findById(Long id): " + id);
   return userRepository.findOne(id);
 }
Пример #6
0
 @Override
 public List<User> findByUsernameAndPassword(String username, String password) {
   LOGGER.debug("findByUsernameAndPassword(String username, String password): " + username);
   return userRepository.findByUsernameAndPassword(username, password);
 }