我需要做getKey()
用這種實體:獲取實體鍵與客體4
@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
更換,但是當我詮釋我getKey()
功能與@Ignore
我得到這個錯誤:
The annotation `@Ignore` is disallowed for this location
所以,我只是評論它。看看它是否會工作。
此外,
當我運行我的應用程序getKey()
函數拋出NullPointerException
如上評論。
那麼,獲得@Entity
密鑰的模式是什麼?
我試圖堅持一個KeyValueVersion實體與'孩子'實體的鍵,值和版本... – xybrek
也正如我所想,@Id是一個龍是自動生成的? – xybrek
然而,實體'價值'是一個'孩子'實體,似乎'孩子'實體不會自動生成Id字段,如果是這樣,我怎樣才能爲子實體生成唯一的ID? – xybrek