title: How does the detached object work in hibernate
body: <p>I know that object is in detached state when we already hit save and we have to re-attach it.</p>
  
  <p>Suppose i have one form with html text fields and there is save button which saves the text in database.</p>
  
  <p>i have thise code</p>
  
  <pre><code> public void edit(Person person) {
    logger.debug("Editing existing person");
  
    // Retrieve session from Hibernate
    Session session = sessionFactory.getCurrentSession();
  
    // Retrieve existing person via id
    Person existingPerson = (Person) session.get(Person.class, person.getId());
  
    // Assign updated values to this person
    existingPerson.setFirstName(person.getFirstName());
    existingPerson.setLastName(existingPerson.getLastName());
    existingPerson.setMoney(existingPerson.getMoney());
  
    // Save updates
    session.save(existingPerson);
   }
  </code></pre>
  
  <p>Now i can hit save any number of time to save the data.</p>
  
  <p>Now does that mean that once i hit save first time , it becomes detached.
  So do i need to do something special for that or it does not matter.</p>
  
  <p>I want to know under what condition i need to program anything about detached state</p>