Doctrine2 - Get entity ID before flush
Is there any way to get an entity ID before the persist/flush? I mean: $entity = new PointData(); $form = $this->createForm(new PointDataType(), $entity); If I try $entity->getId() at this point, it returns nothing. I can get it working by: $em->persist($entity); $em->flush(); (supposing $em = $this->getDoctrine()->getEntityManager(); ) How can I achieve this? If you want to know the ID of an entity before it's been persisted to the database, then you obviously can't use generated identifiers. You'll need to find some way to generate unique identifiers yourself (perhaps some kind of hash