title: How do I get id of merged JPA entity
body: <p>I have a little application where I store entity to DB. I do this in next way:</p>
  
  <pre><code>class Entity {
      privete id;
      String somePropertie;
      // getters and setters
  }
  // In main class
  Entity newEntity = new Entity();
  newEntity.setSomePropertie("somePropertie");
  Entity entity = entityManager.merge(newEntity);
  System.out.println("This is id of stored entity:", entity.getId())
  </code></pre>
  
  <p>The didn't write the jpa annotations here. But the entity is stored to database, but the printed id is 0; I using transaction driven by spring, I need this entity for later updates of the entity id.</p>