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
Post a Comment