The following json data is a part of a document:
"ahashMap" : {
"1" : {
"type" : "STOCK"
}
}
To query above document in MongoDB shell, simply execute the script below:
db.COLS.findOne({'aHashMap.1.type':'STOCK'})
Moreover, to query using Spring Data, it also works for the below codes:
Query q = new Query(Criteria.where("aHashMap.1.type").is("STOCK"));
Col c = mongoOperation.findOne(q, Col.class);
However, it only works for older version of Spring Data, such as 1.7.0. Then I tried to compare the source code with old and new version. For the newest version such as 1.7.2, Spring Data removes the .digit from the query so no result would be found. It would treat as the below query for MongoDB:
db.COLS.findOne({'aHashMap.type':'STOCK'})
I feel confused for this kind of interpretation for Spring Data. Anyone would explain the reason behind and how would I process the query without restructure the document. Thank you.