title: Symfony2 doctrine FindOneOrCreate
body: <p>With propel we have  <strong>findOneOrCreate()</strong></p>
  
  <p>Example.</p>
  
  <pre><code>$bookTag = BookTagQuery::create()
  -&gt;filterByBook($book)
  -&gt;findOneOrCreate();   
  </code></pre>
  
  <p>In doctrine anywhere in the controller We can do something like that.</p>
  
  <pre><code>...................
         $filename='something';
         $document_exists = $em-&gt;getRepository('DemoBundle:Document')
                  -&gt;findOneBy(array('filename' =&gt; $filename));
  
          if (null === $document_exists) {
              $document = new Document();
              $document-&gt;setFilename($filename);
              $em-&gt;persist($document);
              $em-&gt;flush();
          }    
  </code></pre>
  
  <p>Is there another way to achieve this in Doctrine?</p>
  
  <p>Is it OK to call the  Entity Manager inside the Entity Repository?
  Any suggestions?</p>