title: Pass DBRef in mongo query while fetching a document using java
body: <pre><code> db.collectionB.findOne()
   {
      "_id" : NumberLong(24),
      "class" : "Top",
      "type" : DBRef("collectionA", NumberLong(47))
   }
  db.collectionA.findOne()
  {
     "_id" : NumberLong(47),
     "name" : "John",
     "position" : 2 
  }
  </code></pre>
  
  <p>QUERY to be formed : db.collectionB.find({type: DBRef("collectionA", NumberLong(47))});</p>
  
  <p>There are a number of documents in collection A &amp; collectionB. I want to search the documents where "type" in collectionB is referring to document where "_id" is NumberLong(47) in collectionA.</p>
  
  <pre><code>BasicDBObject query =   new BasicDBObject("name","John");
  DBObject db_object = findOne("collectionA",query);
  DBRef myDbRef = new DBRef(db,"collectionB",db_object); 
  DBObject doc = myDbRef.fetch(); 
  System.out.println(doc);
  </code></pre>
  
  <p>It gives the output null. Why?</p>