title: doctrine mapping not found case
body: <p>I have a table A which references table B.</p>
  
  <p>edit: Database engine used is MyISAM.</p>
  
  <p>Doctrine mapping works like a charm, except when I have non valid case in the DB where referenced ID in table A does not really exist in table B.</p>
  
  <p>So when you execute this code:</p>
  
  <pre><code>$objectB = $objectA-&gt;getObjectB();//with lazy load
  </code></pre>
  
  <p>you actually get $objectB proxy object which is <em><strong>not null</strong></em>. So !empty($objectB) will pass.</p>
  
  <p>And when you try to access any property of $objectB, like:</p>
  
  <blockquote>
    <p>$objectB->getName();</p>
  </blockquote>
  
  <p>you get <em>Entity not found exception</em>. There is not way you can predict in your code that $objectB actually does <strong>not exist</strong> and that there's no Name property for $objectB.</p>
  
  <p>$objectB should actually be set to null but that is not happening.</p>
  
  <p>Hibernate has actually mapping property <em>not-found=ignore</em> which sets missing object to <strong>NULL</strong> instead of setting it to Proxy object. Does Doctrine has anything similar?</p>
  
  <p>PS. Of course you can always catch the Entity not found exception, and play around with that. Or you can map the actual objectB_ID field at the table A, but those are not 100% clean solutions.</p>
  
  <p>I hope someone has an answer.</p>
  
  <p>Thank You</p>