我搜索了很多。我仍然无法理解如何将字符串分配给 Google App Engine 实体类ID(密钥)。
所以我有:
Key id;
并且
setId(String id) {
// I know that here I can use id = KeyFactory.createKey("","");
}
但我不知道如何在这里使用createKey
方法将我的字符串赋值给id。请将此处的用户视为我的Entity
班级名称。
P.S。我正在使用 JPA 。
谢谢。
答案 0 :(得分:1)
不确定您的实体是否在寻找,但这对我来说效果很好。
@Entity
class Person{
@Id String personId;
String firstName;
}