要置於數據存儲中的對象將具有一組標記。如何在Java中的Google App Engine數據存儲中使用列表屬性?
public class Model
{
List<String> tagList
...
}
在Python中,Google App Engine具有列表屬性的概念。 Java中的等價概念是什麼(如果存在)以及如何在Java中,在JPA和/或JDO中使用列表屬性?
要置於數據存儲中的對象將具有一組標記。如何在Java中的Google App Engine數據存儲中使用列表屬性?
public class Model
{
List<String> tagList
...
}
在Python中,Google App Engine具有列表屬性的概念。 Java中的等價概念是什麼(如果存在)以及如何在Java中,在JPA和/或JDO中使用列表屬性?
請參見我的博客文章正是在此:Efficient Keyword Search with Relation Index Entities and Objectify for Google Datastore。它討論如何使用關係索引實體和對象化來實現使用列表屬性進行搜索。
總結:
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
包含所有關鍵字的列表屬性(集合)因其Document
實體,並Document
實體是DocumentKeywords
父。
您的博客文章正是我要找的!謝謝.. – onejigtwojig 2011-04-26 02:59:35
在JDO使用
@Persistent
private List<ContactInfo> contactInfoSets;
我希望答案是不使用Python! – onejigtwojig 2011-04-25 13:06:51
任何人都知道JPA的實現? – onejigtwojig 2011-04-25 15:29:36
除Java提供的JPA和JDO外,還有其他數據訪問API選項,例如Objectify。 – topchef 2011-04-25 20:22:41