Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying of java.util.Map #18

Open
bosbeles opened this issue Jul 12, 2018 · 1 comment
Open

Querying of java.util.Map #18

bosbeles opened this issue Jul 12, 2018 · 1 comment

Comments

@bosbeles
Copy link

if(rsql != null) {
QueryConversionPipeline pipeline = QueryConversionPipeline.defaultPipeline();
Condition 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.

@emreesirik
Copy link

is there any idea? why we can not query for Map attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants