title: Doctrine EventListener onFlush does not save original entity
body: <p>I've been struggling with an annoying issue for a while.  I'm trying to create Notification entities associated to InventoryItems that expire.</p>
  
  <p>These InventoryItems are generated automatically for users, but users can edit them and set expiry date on them individually.  Upon saving, if an InventoryItem has an expiry date, a Notification entity is generated and associated to it.  So these Notification entities are created when an entity is updated and hence onPersist event is not going to work.</p>
  
  <p>Everything seems to work fine and Notifications are generated upon saving InventoryItems as expected.  Only problem is, when a Notification is created for the first time, even though it's saved properly, changes to the InventoryItem are not saved.  That is a Notification with correct expiry date is created, but the expiry date is not saved on the InventoryItem.</p>
  
  <p>Here's my onFlush code:</p>
  
  <pre><code> public function onFlush(OnFlushEventArgs $args)
  {
      $em  = $args-&gt;getEntityManager();
      $uow = $em-&gt;getUnitOfWork();
      foreach ($uow-&gt;getScheduledEntityUpdates() as $entity) {
          if ($entity instanceof NotificableInterface) {
            if ($entity-&gt;generatesNotification()){
                $notification = $this-&gt;notificationManager-&gt;generateNotificationForEntity($entity) ;
                if ( $notification ) {
                    $uow-&gt;persist($notification) ; 
                }
                $entity-&gt;setNotification($notification) ; 
                $uow-&gt;persist($entity);
                $uow-&gt;computeChangeSets();
            }
          }
      }
  }
  </code></pre>
  
  <p>The problem only occurs the first time a Notification is associated to an entity, i.e. the first time an expiry date is set on an InventoryItem.  In later instances when expiry date is updated, the update is reflected correctly on both the Notification and InventoryItem.</p>
  
  <p>Any ideas or suggestions would be appreciated.</p>
  
  <p>Thanks</p>