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

No api to create attributes for SQLParser when attributes are defined in a seperate file #286

Open
ldwnt opened this issue Jun 28, 2021 · 2 comments

Comments

@ldwnt
Copy link

ldwnt commented Jun 28, 2021

public class RecallItem {
...
    public String getStatus() {
        return status;
    }
...
}

public class CQRecallItem {
...
    public static final Attribute<RecallItem, String> STATUS = new SimpleNullableAttribute<RecallItem, String>("STATUS") {
        public String getValue(RecallItem recallitem, QueryOptions queryOptions) { return recallitem.getStatus(); }
    }
...
}

SQLParser provides an api to register attributes from the pojo class, but not a seperate class:

public static <O> SQLParser<O> forPojoWithAttributes(Class<O> pojoClass, Map<String, ? extends Attribute<O, ?>> attributes)
@npgall
Copy link
Owner

npgall commented Jun 28, 2021

I don't think it cares which class the attributes are defined in. The attributes just need to read from objects of type pojoClass.

There are other methods in the superclass of SQLParser for registering attributes in different ways.

Does the following work?

SQLParser<RecallItem> parser = SQLParser.forPojo(RecallItem.class);
parser.registerAttribute(CQRecallItem.STATUS);

@ldwnt
Copy link
Author

ldwnt commented Jun 29, 2021

I don't think it cares which class the attributes are defined in. The attributes just need to read from objects of type pojoClass.

There are other methods in the superclass of SQLParser for registering attributes in different ways.

Does the following work?

SQLParser<RecallItem> parser = SQLParser.forPojo(RecallItem.class);
parser.registerAttribute(CQRecallItem.STATUS);

parser.registerAttribute results in failure with sql "select * from collection where status = 'ACTIVE'" and it requires query with upper-case field "STATUS" instead of "status". However parser.forPojoWithAttributes requires query with lower-case field 'status'. Such behavior is confusing. Besides, if RecallItem.status is private this field can't be queried either, which is not documented in the guide.

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