title: Spring data save does not update the PK in the persistence context?
body: <p>Everytime I use the method save of a JPA Spring data repository it give me back a new object and the Autogenerated PK are not updated in the saved object.</p>
  
  <p>Do I have to update my local object PK with the returned by save method manually?</p>
  
  <p>Code:</p>
  
  <pre><code>private void saveProject(){
          Project savedProject = projectRepository.save(projectModel.getProject());
  }
  </code></pre>
  
  <p><strong>savedProject</strong> is not the same as <strong>projectModel.getProject</strong></p>
  
  <pre><code>@Entity
  @Table(name = "project", schema = "public")
  public class Project {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Integer id;
  
      @LazyCollection(LazyCollectionOption.FALSE)
      @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
      List&lt;User&gt; users;
      [...]
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>@Entity
  @Table(name = "user", schema = "public")
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Integer id;
  
      String name;
  }
  </code></pre>
  
  <p>So, the user PK is gerenated in Mysql, and everytime I save the project a new User is created because the user in the app is still PKless...</p>