英文:
GCP Datastore Querying on nested entity references (entityB.name)
问题
I am having trouble figuring out if GCP Datastore supports querying nested properties of an entity.
My use case right now is like so:
-> Application
I want to try querying 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 Spring's GCP Datastore abstraction through their DatastoreTemplate, but this doesn't seem related given that when I try to 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!
英文:
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!
答案1
得分: 2
看起来你正在使用一个引用,而不是一个嵌入式实体。模块中的应用程序实际上是对应用程序实体的关键引用。因此,模块实体上的应用程序的值不会被索引。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论