title: How do I create a raw MongoDB Query using Doctrine2 and Symfony2
body: <p>I'm trying to query embedded documents using dot notation -- here are some examples:</p>
  
  <p><a href="http://www.mongodb.org/display/DOCS/Dot+Notation+%28Reaching+into+Objects%29" rel="nofollow">http://www.mongodb.org/display/DOCS/Dot+Notation+(Reaching+into+Objects)</a></p>
  
  <p>Since I'm hung up on the DQL/QueryBuilder API I'd like to just pass raw queries through Doctrine. I can't seem to figure this out within the constructs of Symfony2. The only code I can be sure of is:</p>
  
  <pre><code>$dm = $this-&gt;get('doctrine.odm.mongodb.document_manager');
  $dm-&gt;getSchemaManager()-&gt;ensureIndexes();
  $repo = $dm-&gt;getRepository('MyBundle:MyDocument');
  $qb = $repo-&gt;createQueryBuilder();
  
  // insert magic here
  
  $query = $qb-&gt;getQuery();
  $result = $query-&gt;execute();
  </code></pre>
  
  <p>Here's how dot notation works:</p>
  
  <pre><code>$dm = $this-&gt;get('doctrine.odm.mongodb.document_manager');
  $dm-&gt;getSchemaManager()-&gt;ensureIndexes();
  $repo = $dm-&gt;getRepository('MyBundle:MyDocument');
  $qb = $repo-&gt;createQueryBuilder();
  
  $qb
      -&gt;field('embedded_document_field.field1')-&gt;equals(1)
      -&gt;field('embedded_document_field.field2')-&gt;equals('foo')
  ;
  
  $query = $qb-&gt;getQuery();
  $result = $query-&gt;execute();
  </code></pre>