Hi
I am trying to retrieve a document based on the _id condition,the _id is a composite key
Sample document looks like this
{
"_id" : {
"business_id" : "b15000077",
"source" : "web"
},
"value" : {
"Sum" : 4,
"avg" : 4,
"count" : 1
}
}
from mongo console
db.collection_name.find({ _id: {"source":"web","business_id":"b15000077"}})
gets me result
From Java
I am using morphia to get this document and my query looks like this
Query<REntity> q = datastore.createQuery(REntity.class).field("_id").equal("{'source':'web','business_id':'b15000077'}");
REntity r = q.get();
I have tried all variation of the single quote and escaped doubled quote ,
My Entityclass looks like
@Entity(value = "collection_name",noClassnameStored = true)
public class REntity {
@Id
public String id;
//also tried this as a class IdClass- member web,business_id
public ValueClass value;
...}
Being New to Mongo i just cant figure out where the problem,i believe its the way my query to morphia-mongo is constructed,Please point me in right direction