0

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.

1
  • 1
    There seems to be a flaw in QueryMapper introduced in 1.7.1. I've created DATAMONGO-1269 for it. Commented Aug 5, 2015 at 6:12

1 Answer 1

1

This bug is fixed in Spring Data MongoDB 1.8.0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.