0

创建实体后:

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity employee = new Entity("Employee");

如何设置可索引的列表属性?就像说:

employee.setProperty("tag", "manager", "corrupted", ...);
//  "tag" is the property name, 
//  "manager", "corrupted".. are the values in the list.
4

1 回答 1

1

查看javadoc,您可以将 Collection 作为 setProperty 的第二个参数。

例如

List<String> tags = new ArrayList<String>();
tags.add("manager");
tags.add("corrupted");

employee.setProperty("tag", tags);
于 2013-01-05T23:47:39.630 回答