【发布时间】:2012-10-01 14:33:48
【问题描述】:
我需要用这种实体做getKey():
@Entity
public class Value {
@Id
private long id;
private byte[] value;
com.googlecode.objectify.Key<Value> getKey() {
return com.googlecode.objectify.Key.create(Value.class, id); // When executed this line throws NullPointerException
}
// Code omitted
}
但是,我之前在版本 3 中使用的模式似乎不再适用。
@Transient 被 @Ignore 替换,但是当我用 @Ignore 注释我的 getKey() 函数时,我得到了这个错误:
The annotation `@Ignore` is disallowed for this location
所以我只是把它注释掉了。看看它是否会起作用。
此外,
当我运行我的应用程序时,getKey() 函数会抛出 NullPointerException,如上所述。
那么,获取@Entity 密钥的模式是什么?
【问题讨论】:
标签: google-app-engine objectify