[英]How do you use list properties in Google App Engine datastore in Java?
An object to be placed in the datastore will have a set of tags. 放置在数据存储区中的对象将具有一组标记。
public class Model
{
List<String> tagList
...
}
In Python, the Google App Engine has the notion of list properties. 在Python中,Google App Engine具有列表属性的概念。 What is the equivalent notion in Java (if it exists) and how would you use list properties in Java, in JPA and/or in JDO?
Java中的等效概念(如果存在)以及如何在Java,JPA和/或JDO中使用列表属性?
See my blog post exactly on this: Efficient Keyword Search with Relation Index Entities and Objectify for Google Datastore . 请参阅我的博客文章: 关键字索引实体的高效关键字搜索和Google Datastore的Objectify 。 It talks about implementing search with list properties using Relation Index Entities and Objectify.
它讨论了使用关系索引实体和Objectify实现列表属性的搜索。
To summarize: 总结一下:
Query<DocumentKeywords> query = ofy.query(DocumentKeywords.class);
for (String keyword : keywords) {
query = query.filter("keywords", keyword);
}
Set<Key<Document>> keys = query.<Document>fetchParentKeys();
Collection<Document> documents = ofy.get(keys).values();
where DocumentKeywords
contains a list property (collection) of all keywords for its Document
entity, and Document
entity is a parent for DocumentKeywords
. 其中
DocumentKeywords
包含其所有关键字的列表属性(集合) Document
实体和Document
实体是一个父DocumentKeywords
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.