title: Spring mongo query collection on property with underscore char
body: <p>I'm building a query to retrieve elements from a mongo collection, using MongoTemplate. The query criteria contains a property with an underscore, that somehow is replaced with '._', making the query always return 0 elements.</p>
  
  <pre><code>Criteria matchingCriteria = Criteria
  .where("entries").elemMatch(Criteria.where("app_id").is(appId))
  </code></pre>
  
  <p>Looking to the logs I can see the generated query as follows:</p>
  
  <pre><code>o.s.data.mongodb.core.MongoTemplate: find using query: { "entries" : { "$elemMatch" : { "app._id" : "5834718ab0"}}} fields: null for class: Ranking in collection: ranking
  </code></pre>
  
  <p>I've already tried with BasicQuery, slashing underscore with '\\', and using the unicode “app\u005Fid". None of them worked. It's important to note that a collection with name "app" exists in my database.</p>
  
  <p>The behaviour doesn't look standard. When I use another property with an underscore the value is not replaced: </p>
  
  <pre><code>Criteria matchingCriteria = Criteria .where("entries").elemMatch(Criteria.where("unique_app_id").‌​is(appId)) 
  </code></pre>
  
  <p>The logs: </p>
  
  <pre><code>o.s.data.mongodb.core.MongoTemplate find using query: { "entries" : { "$elemMatch" : { "unique_app_id" : "1131706359"}}} fields: null for class: class Ranking in collection: ranking
  </code></pre>
  
  <p>entries is an array with collection with the following format:</p>
  
  <pre><code>{
      "instanceId" : "654ba2d16579e",
      "app_id" : "583471adb0",
      "unique_app_id" : "554577506",
      "value" : 169
   }
  </code></pre>
  
  <p>It's worth mentioning that the same query (without the underscore replacement) works fine in a mongo IDE (Robomongo in this case).</p>
  
  <p>I'm using spring-boot-starter-data-mongodb 1.4.1.RELEASE.</p>
  
  <p>I'm really out of ideas right now.</p>
  
  <p>Any suggestion ?</p>