java - How to find value of innerattributes in mongodb? -


i new mongodb.and want values of time in json like:

{ "_id" : { "$oid" : "4ceb753a70fdf877ef5113ca"}, "loginrequest" : { "time" : "11-06-2012 11:59:33", "innerattr4" : "innervalue4"} } { "_id" : { "$oid" : "4ceb753a70fdf877ef5113cb"}, "loginrequest" : { "time" : "11-06-2012 12:34:05", "innerattr4" : "innervalue4"} } 

after searching found use dot notation. dot notation not working me in java. can tell me how this?

i used dot notation in manner. returns null.

        string selectedcollection = "user01"; //will contain selected username         dbcollection coll = db.getcollection(selectedcollection);          arraylist<string> result = new arraylist<string>();         //dbobject obj = coll.findone("loginrequest.time");         basicdbobject query = new basicdbobject();         basicdbobject field = new basicdbobject();         field.put("loginrequest.time", 1);         dbcursor cursor = coll.find(query,field);         while (cursor.hasnext()) {             basicdbobject obj = (basicdbobject) cursor.next();             result.add(obj.getstring("loginrequest.time"));             system.out.println(obj.getstring("loginrequest.time") );         } 

it works fine if replacing loginrequest.time loginrequest everywhere. help.

(basicdbobject(obj.get("loginrequest"))).getstring("time") 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -