title: Doctrine MongoDB find by id
body: <p>I'm using odm mongo doctrine and I have to document-classes</p>
  
  <pre><code>class Thing
  {
  /**
   * @MongoDB\Id
   */
  protected $id;
  
   /**
    * @MongoDB\ReferenceOne(targetDocument="Bundle1:Other")
    */
  protected $other;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class Other
  {
  /**
   * @MongoDB\Id
   */
  protected $id;
  }
  </code></pre>
  
  <p>so in the database a thing looks like : </p>
  
  <pre><code>{
    "_id":ObjectId("43z758634875adf"),
    "other":ObjectId("38z287348d8se")
  }
  </code></pre>
  
  <p>How can I now query for things where other is a given id ? </p>
  
  <pre><code>    $dm=$this-&gt;mongo-&gt;getManager();
              $answers=$dm
                  -&gt;createQueryBuilder('Bundle1:Thing')
                  -&gt;field('other')-&gt;equals("ObjectId(516c0061975a299edc44b419)")  // &lt;-- ?
                  -&gt;getQuery()
                  -&gt;execute()-&gt;count();       
  </code></pre>
  
  <p>This produces a wrong mongo query</p>
  
  <blockquote>
    <p>MongoDB query:
    {"find":true,"query":{"other":"ObjectId(516c0061975a299edc44b419)"},"fields":[],"db":"maself","collection":"thing"}
    [] []</p>
  </blockquote>
  
  <p>When I use </p>
  
  <blockquote>
    <p>->field('other')->equals("516c0061975a299edc44b419")</p>
  </blockquote>
  
  <p>the query is also wrong </p>
  
  <blockquote>
    <p>MongoDB query:
    {"find":true,"query":{"other":"516c0061975a299edc44b419"},"fields":[],"db":"maself","collection":"thing"}
    [] []</p>
  </blockquote>
  
  <p>So how can I search for thing where other id equals an objectId ? </p>