问题描述
要置于数据存储中的对象将具有一组标记。
An object to be placed in the datastore will have a set of tags.
public class Model
{
List<String> tagList
...
}
在Python中,Google App Engine具有列表属性的概念。什么是Java中的等价概念(如果存在)以及如何使用Java中的JPA和/或JDO中的列表属性?
In Python, the Google App Engine has the notion of list properties. 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?
推荐答案
请参阅我的博客文章:。它介绍了如何使用关系索引实体和物品化实现与列表属性的搜索。
See my blog post exactly on this: Efficient Keyword Search with Relation Index Entities and Objectify for Google Datastore. It talks about implementing search with list properties using Relation Index Entities and 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();
其中 DocumentKeywords
包含一个list属性(collection )的 Document
实体和 Document
实体的所有关键字是 DocumentKeywords
。
where DocumentKeywords
contains a list property (collection) of all keywords for its Document
entity, and Document
entity is a parent for DocumentKeywords
.
这篇关于如何在Java中的Google App Engine数据存储中使用列表属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!