We have a structure which embeds a object called survey with it's own _id. For example:
The type of survey._id is ObjectId as it is stored in Mongo.Code:{ ... ... survey { _id : 4f595cafda06031df450d8ca ... } }
I wrote a finder that looks like this:
Structurally, the class SurveySnapshot contains a member of type Survey called survey which then contains a String of type id:Code:@Query(value="{\"survey._id\" : ?0}") Page<SurveySnapshot> findBySurveyId(String surveyId, Pageable page, Sort sort);
But it's not returning anything and the data is there.Code:class SurveySnapshot { ... private Survey survey ... } class Survey { private String id; }
Issuing this query to a MongoQuery tool produces results I need:
{"survey._id" : ObjectId("4f595cafda06031df450d8ca")}
However, writing this code:
Throws a com.mongodb.JSONParseException...Code:new BasicQuery("{\"survey._id\" : ObjectId(\"4f595cafda06031df450d8ca\")}")
Am I doing something wrong in constructing the query in java?
Thanks.
-AP_


Reply With Quote