title: Hibernate update with EntityManager
body: <p>I am using Hibernate 4.1.7 and trying to update object, but theres no documentation how it should be done. Currently, I am doing this:</p>
  
  <pre><code>    Person person = personDao.getPersonById(1);
      person.setAge(23);
      person.setLastname("McName");
      person = personDao.update(person);
  </code></pre>
  
  <p>In PersonDao update looks like:</p>
  
  <pre><code>    public Person update(Person person) {
        return entityManager.merge(person);
      }
  </code></pre>
  
  <p>In PersonDao getPersonById is:</p>
  
  <pre><code>    public Person getPersonById(int id) {
        personQuery = entityManager.createNamedQuery("Person.findPerson", Person.class);
        personQuery.setParameter("id", id);
        return personQuery.getSingleResult();
      }
  </code></pre>
  
  <p>Also I have defined named query inside Person class and is here:</p>
  
  <pre><code>    @NamedQuery(name="Person.findPerson", query="SELECT p FROM Person p WHERE p.id = :id")
  </code></pre>
  
  <p>By using that my Person won't be updated, how should I implement update using hibernate?</p>