title: How to do this MongoDB query using java?
body: <p>I have to write a simple <code>MongoDB</code> query using <code>java</code> but am not able to do it.</p>
  
  <p>The mongo query looks like this: </p>
  
  <pre><code>db.yourCollection.find({"$where" : "this.startDate &lt; this.endDate"})
  </code></pre>
  
  <p>I have to write the above query using the <code>QueryBuilder</code> class. But am not able to do it in <code>MongoDB</code> <code>java</code> driver.</p>
  
  <pre><code>BasicDBObject document = new BasicDBObject();
  document.put("id", 1001);
  document.put("intValue", 1200);
  document.put("updateValue", 2100);
  
  DBObject query = QueryBuilder.start("intValue").lessThan("updateValue").get();
  DBCursor cursor = collection.find(query);
  while (cursor.hasNext()) {
  System.out.println("Result : -"+cursor.next());}
  </code></pre>
  
  <p>The above code does not return any results. But if changed to <code>updateValue</code> into <code>2100</code> it is giving result. My question here is <code>lessThan</code> takes object as input parameter. Then how can I pass document field as an input parameter?</p>