title: Spring Data JPA - save() method working perfectly fine without using the returned entity
body: <p>Below is the Javadoc specific for the save() method in Spring Data JPA</p>
  
  <pre><code>/**
   * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the
   * entity instance completely.
   * 
   * @param entity
   * @return the saved entity
   */
  &lt;S extends T&gt; S save(S entity);
  </code></pre>
  
  <p>and also below resource clearly states that we need to use the returned objected to ensure that we perform further operations on the saved entity.</p>
  
  <p><a href="https://stackoverflow.com/questions/8625150/why-to-use-returned-instance-after-save-on-spring-data-jpa-repository">Why to use returned instance after save() on Spring Data JPA Repository?</a></p>
  
  <p>However, in my below code my save() entity works fine without</p>
  
  <pre><code>public void createEmployee(Employee employee) throws Exception {
      try {
          employee.setEmployeeName("alan");   
          employeeRepo.save(employee);
          employee.setEmployeeType("Permanent");  
          employeeRepo.save(employee); 
      } catch (Exception e) {
          throw new Exception(e);
      }
  
  }
  </code></pre>
  
  <ol>
  <li>Why is the above code working without a return type   </li>
  <li>Tests seem to show that data is being persisted perfectly fine, but i was under the impression that we need to use the returned entity to ensure correct persistence.</li>
  </ol>
  
  <p>Am I doing something inadvertently right/wrong ? I am new to spring-data and would like to understand save() method perfectly since a lot of my current application is CRUD based. Thanks.</p>