GCP Datastore查询嵌套实体引用(entityB.name)。

huangapple go评论76阅读模式
英文:

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
  -&gt; Application

Module

GCP Datastore查询嵌套实体引用(entityB.name)。

Application

GCP Datastore查询嵌套实体引用(entityB.name)。

@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&lt;? extends BaseEntity&gt; query = Query.newEntityQueryBuilder()
	.setKind(&quot;module&quot;) 
	.setFilter(PropertyFilter.eq(&quot;application.name&quot;, &quot;UserApp&quot;))
	.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 = &quot;UserApp&quot;

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.

huangapple
  • 本文由 发表于 2020年8月6日 02:44:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63271652.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定