java - Complex query in Morphia -


in method java, pass parameter collection mongodb complex query one:

{"$or": [{"$and": [{"contextid": "akka"}, {"messageid": "pippo"}]},          {"$and": [{"domain": "niguarda"}, {"hostname": {"$ne": "hostserver"}}]}         ] } 

the string contains query variable , passed parameter in query string.

i tried pass query parameter method criteria

(querydb.criteria("     {"$or": [         {"$and": [{"contextid": "akka"}, {"messageid": "pippo"}]},         {"$and": [{"domain": "niguarda"}, {"hostname": {"$ne": "hostserver"}}]}]     }" )  

but not work.

any suggestions?

what you're trying

query q = dao.createquery(); q.or(  q.and(new criteria[]{ dao.createquery().filter("contextid").equal("akka"),                        dao.createquery().filter("messageid").equal("pippo") }),  q.and(new criteria[]{ dao.createquery().filter("domain").equal("niguarda"),                        dao.createquery().filter("hostname").notequal("hostserver") }) ); 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -