-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: JSON
-
None
Now we use Spring Boot v.2.1.3 and faced with problem associated with searching by UUID in mongodb.
Before(in Spring Boot v.1.5.8) we executed the next code:
Lists.newArrayList(mongoTemplate.getCollection("entities") .distinct("name", new BasicQuery("\{\"_id\":{\"$uuid\": \"0021cf0a-9094-49ad-b716-c9c019134bbe\" }}").getQueryObject()));
and we got the correct result,
But now this approach doesn't work
I write:
Lists.newArrayList(mongoTemplate.getCollection("entities") .distinct("name", new BasicQuery(new Document("_id", "\{\"$uuid\": \"0021cf0a-9094-49ad-b716-c9c019134bbe\" }")).getQueryObject(), String.class));
and we get the error
Command failed with error 2 (BadValue): 'unknown operator: $uuid' on server localhost:27017. The full response is \{ "ok" : 0.0, "errmsg" : "unknown operator: $uuid", "code" : 2, "codeName" : "BadValue" }
I saw the ticket https://jira.spring.io/browse/DATAMONGO-2029, but It doesn't help us
I have created the ticket DATAMONGO-2397 , and now we use deprecated com.mongodb.util.JSON API, for example:
DBObject legacy = (DBObject) JSON.parse("{\"_id\":{\"$uuid\": \"0021cf0a-9094-49ad-b716-c9c019134bbe\" }}"); org.bson.Document filter = new org.bson.Document(legacy.toMap()); template.getCollection("entities") .distinct("firstName",filter,String.class)
but it is deprecated API, can you add $uuid parsing to the JsonReader, as it was suggested in the comment
- mentioned in
-
Page Loading...