title: Doctrine2 - Get entity ID before flush
body: <p>Is there any way to get an entity ID before the persist/flush?
  I mean:</p>
  
  <pre><code>$entity = new PointData();
  $form   = $this-&gt;createForm(new PointDataType(), $entity);
  </code></pre>
  
  <p>If I try <strong>$entity->getId()</strong> at this point, it returns nothing.</p>
  
  <p>I can get it working by:</p>
  
  <pre><code>$em-&gt;persist($entity);
  $em-&gt;flush();
  </code></pre>
  
  <p>(supposing <strong>$em = $this->getDoctrine()->getEntityManager();</strong>)</p>
  
  <p>How can I achieve this?</p>