【发布时间】:2012-05-25 10:54:21
【问题描述】:
根据此处的问答: Get an Objectify Entity's Key
对于持久化对象,获取实体键:
@Transient
Key<Categoria> getKey() {
return new Key<Categoria>(Categoria.class, id);
}
不返回相同的键:
Objectify ofy = ObjectifyService.begin();
Key<Categoria> key = ofy.getFactory().getKey(someobject);
还是应该?
我的模型如下所示:
@Entity
class Categoria{
@Parent
private Key<Someclass> parentKey;
@Transient
Key<Categoria> getKey() {
return new Key<Categoria>(Categoria.class, id);
}
// Code omitted
}
【问题讨论】:
-
也许它们不是相同的 (
==) 键,但应该相等 (.equals())。不是吗? -
我实际上是通过它们的字符串表示来比较键,比如 testobjectKey.getString()
标签: google-app-engine objectify