When saving a Objectify Entity to the Appengine datastore, is it possible to save a custom Datastore "Key" instead of the auto generated Key hash?
0
votes
1 Answers
2
votes
You can use any String or long and annotate it as being the key, like this:
import javax.persistence.Id;
public class MyEntityClass {
@Id
private String myCustomKey;
public MyEntityClass(String keyId) {
this.myCustomKey = keyId;
}
}
Then you can retrieve it again using:
MyEntityClass object = ofy().get(new Key<MyEntityClass>(MyEntitiyClass.class, "specificKeyId"));