Announcement Announcement Module
Collapse
No announcement yet.
Update operation in CRUD Repositoty Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update operation in CRUD Repositoty

    Hi!
    CRUD repo should have update operations, but there is only CUD. There is only "save" for update, should I use it?
    Actually, I have next flow. In my Spring MVC Application I have edit method, it looks like

    Code:
    @RequestMapping(value = "/{id}", method = RequestMethod.POST)
        public String edit(@PathVariable("id") Long id, @Valid User user, BindingResult bindingResult) {
            if (bindingResult.hasErrors()) {
                user.setId(id);   //Very bad
                return "usersEdit";
            }
            user.setId(id);  //Bad
            repository.save(user);
            return "redirect:/users/" + id;
        }
    But I completely dislike setting id. I think this is common usage of Spring MVC and Spring Data. Also I want to handle case which deleting user during editing. How I should solve such issue?
Working...
X