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