I am having trouble figuring out if GCP Datastore supports querying nested properties of an entity.
My use case right now is like so:
Module
-> Application
Module
Application
@Entity
class Module {
Long id;
@Reference
Applicaiton application;
}
@Entity
class Application {
Long id;
String name;
}
I want to try query the module based on its nested Application
name. I have tried providing the filter like so without success:
Query<? extends BaseEntity> query = Query.newEntityQueryBuilder()
.setKind("module")
.setFilter(PropertyFilter.eq("application.name", "UserApp"))
.build();
I'm using Springs GCP datastore abstraction through their DatastoreTemplate, but this doesn't seem related given that when I try run the GQL on the GCP console I get no results back either.
SELECT * FROM module WHERE application.name = "UserApp"
Thanks for taking the time to read through this. Any help with this is greatly appreciated!
It looks like you are using a Reference and not an embedded entity. The Application in module is really a key reference to an Application entity. Thus the values of application are not an indexed on the Module entity.