Description
Joseph Blair opened DATAMONGO-2193 and commented
I have a field id
in a nested object, which serves as a reference to other Mongo objects, so it is generally a Mongo-style ObjectId represented as a string. It is declared as follows:
@Field("id")
private String id;
Upon upgrading from Spring Data MongoDB 1.10.5 to 2.1.1 for compatibility with Server 3.6, queries on this field now erroneously return no results. I suspect what's happening is that the query should be executed as follows (this is what is returned by query.toString()
):
db.myCollection.find({"group.id": "5acf..."})
But instead, it's being executed as:
db.myCollection.find({"group.id": ObjectId("5acf...")})
That suspicion seems to be confirmed by the fact that changing an existing document, directly in the database, from "id": "5acf..."
to "id": ObjectId("5acf...")
causes it to be returned by the query.
It looks like this might be the same bug described by DATAMONGO-1798. I wanted to confirm if that's the case, and see if there is some other alternative solution since I assume 2.2 won't see general release for at least a few months. It was working as expected prior to the version upgrade, so we're really just looking for a way to restore the previous behavior.
Affects: 2.1.4 (Lovelace SR4)
Issue Links:
- DATAMONGO-2205 Searching by nested object with ID doesn't return any result
Referenced from: pull request #640
Backported to: 2.1.5 (Lovelace SR5)