Example #1
0
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public boolean removeUser(@PathVariable Long id) {
   User u = session.get(User.class, id);
   if (u != null) {
     session.delete(u);
     session.flush();
     System.out.println("Deleted user: " + u.getId());
     return session.get(User.class, id) == null;
   }
   return false;
 }
Example #2
0
  @RequestMapping(value = "/", method = RequestMethod.POST)
  public User createUser(@RequestBody User user) {
    System.out.println(user);

    if (user.getLogin() == null) {
      user.setLogin(user.getName() + " " + user.getSurname());
    }

    session.saveOrUpdate(user);
    if (user.getId() != null) {
      return user;
    }
    return null;
  }