Querying of java.util.Map
if(rsql != null) { QueryConversionPipeline pipeline = QueryConversionPipeline.defaultPipeline(); Condition<GeneralQueryBuilder> condition = pipeline.apply(rsql, Notification.class); Criteria criteria = condition.query(new MongoVisitor()); query.addCriteria(criteria); }
Suppose you have a class Notification.class with a field: private Map<String, Object> data; And you're querying "data.category==cat-1" where category is a key of a map. Then EntityFieldTypeResolver throws a null pointer exception. I changed its apply method as follows: @Override public Class> apply(FieldPath path, Class> root) { String[] splitField = path.asKey().split("\.", 2); Field field = getField(root, splitField[0], true); if(field == null) { return Object.class; }
if(splitField.length == 1) {
return normalize(field);
} else {
return apply(new FieldPath(splitField[1]), normalize(field));
}
}
But is this the right approach? Is it possible to add map inside maps etc. a more generic approach I mean.
is there any idea? why we can not query for Map attributes