title: How to update object parameter in DAO?
body: <p>I'm new at Java and trying to understand how MVC architecture goes. <em>Forgive me if I'm wasting your time</em>. I wrote a DAO Service, it handles the crud model (get, read, update, delete).</p>
  <pre><code>   public List&lt;User&gt; getUsers();
     public User getUser(Long userId);
     public void createUser(User user);
     public void updateUser(User user);
     public void delete(Long userId);
  }
  </code></pre>
  <p>here are my abstract DAO functions.</p>
  <pre><code>    @Override
      @Transactional
      public void updateUser(User user) {
          em.merge(user);
      }
  </code></pre>
  <p>and the controller:</p>
  <pre><code>@PutMapping(value = &quot;/{userId}&quot;, produces = &quot;application/json&quot;)
      public ResponseEntity&lt;UserDTO&gt; update(@PathVariable Long userId, @RequestBody UserDTO user){
          try{
              service.updateUser(user);
              return new ResponseEntity&lt;&gt;(HttpStatus.OK);
          } catch (HttpClientErrorException p){
              return new ResponseEntity&lt;&gt;(HttpStatus.BAD_REQUEST);
          } catch (HttpServerErrorException.InternalServerError u){
              return new ResponseEntity&lt;&gt;(HttpStatus.INTERNAL_SERVER_ERROR);
          }
      }
  </code></pre>
  <p>in the service:</p>
  <pre><code>    @Override
      public void updateUser(UserDTO user) {
          userDAO.updateUser(ApiDTOBuilder.userDTOToUser(user));
      }
  </code></pre>
  <p>How can I pass the userId and set the new parameters into the current user object?</p>