Spring Data JPA Update Method
If the goal is to modify an entity, you don't need any update method. You get the object from the database, modify it, and JPA saves it automatically:
User u = repository.findOne(id);
u.setFirstName("new first name");
u.setLastName("new last name");
If you have a detached entity and want to merge it, then use the save()
method of CrudRepository
:
User attachedUser = repository.save(detachedUser);