我嵌套POJO象下面这样:SQL表达式一样嵌套obejct
class Parent{
String name;
Child child;
}
class Child{
String name;
}
会是什么类似SQL的查询的名字相匹配的孩子呢?
到目前为止,我有这样的:
CQNParser<Parent> parser = CQNParser.forPojoWithAttributes(Parent.class, AttributeBytecodeGenerator.createAttributes(Parent.class));
ParseResult<Notification> parseResult = parser.parse("equal(\"child\".\"name\" , \"John\")");
Prent p = new Parent().setChild(new Child().setName("John"));
boolean matches = parseResult.getQuery().matches(p, parseResult.getQueryOptions());
这给我 Failed to parse query at line 1:21: mismatched input '.' expecting ','
感谢@npgall,据我所知,'AttributeBytecodeGenerator.createAttributes(Parent.class)'返回带有'name'和'child'键的地图...我期望得到带有'name'的平面地图,''孩子'和'child.name' attrubites –
好点。我更新了答案以提供更多关于这与'AttributeBytecodeGenerator'相关的信息 – npgall