gpt4 book ai didi

java - 如何在应用程序引擎实体中存储可索引列表/集合?

转载 作者:行者123 更新时间:2023-12-01 14:57:24 24 4
gpt4 key购买 nike

创建实体后:

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.

最佳答案

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

例如

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

employee.setProperty("tag", tags);

关于java - 如何在应用程序引擎实体中存储可索引列表/集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14177176/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com