java - Include Null check in MongoRepository query by example -


i trying find collection match search criteria using mongorepository using following method:

<s extends t> page<s> findall(example<s> example, pageable pageable); 

to building examplematcher fields included in search. so:

 private examplematcher buildmatcher(formsearchparameters formsearchparameters) {      examplematcher examplematcher = examplematcher.matching()              .withignorepaths("f1", "f2", "f3", "f4" , "f5");      if (!stringutils.isempty(formsearchparameters.getname())) {         examplematcher = examplematcher.withmatcher("name", match -> match.regex());     }      if (!stringutils.isempty(formsearchparameters.getfoo())) {         examplematcher = examplematcher.withmatcher("foo", matcher -> matcher.exact().ignorecase());     }      if (null != formsearchparameters.getfilter()) {         examplematcher = examplematcher.withmatcher("filter", matcher -> matcher.exact());     }     else {         examplematcher = examplematcher.withignorepaths("filter");     }      return examplematcher.withincludenullvalues(); } 

however need add last check field (say nullfield) null. cant seem find information on how go in documentation.

i have tried adding following nullfield null in example model provided seems ignored.

.withmatcher("nullfield", matcher -> matcher.exact()) 

many thanks


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -