title: hibernate java curiosity - after saving the object, both the object to save and the saved one have id set
body: <p>I have the following simple code:</p>
  
  <pre><code>@Test
  public void saveExpense() {
      // Create dummy Expense object i.e. { "description": "Short Description", "date": etc } 
      Expense expenseToSave = ExpenseHelper.createExpense("Short Description", new Date(), user);
  
      Expense savedExpense = expenseService.save(expenseToSave);
  
      // What is strange, is that here, both expenseToSave and savedExpense have id set to 1 for example; after save the expense should have an id; 
  
      Expense expected = ExpenseHelper.createExpense("Short Description", new Date(), user);
      // Check if expected object is equal to the saved one
      Assert.assertTrue(expected.equals(expenseService.findByDescription("Short Description")));
  }
  </code></pre>
  
  <p>Normally I would expect that expenseToSave to be without id and savedExpense with id, but both have id after save. Why?</p>
  
  <p>That made another variable to be necessary and complicate the test.</p>
  
  <p>Thanks.</p>