google app engine - Objectify does not fetch by String ID -
google app engine - Objectify does not fetch by String ID -
i have datastore kind in id field string
ofy().load().type( scores.class ).id( playername ).now();
this fetches null. have confirmed entity given playername exists. not happen kind id long.
code scores class
import com.googlecode.objectify.key; import com.googlecode.objectify.annotation.entity; import com.googlecode.objectify.annotation.id; import com.googlecode.objectify.annotation.parent; @entity public class scores { @parent public key<rankerroot> parentkey; @id public string playername; public int value; }
you need sure giving objectify plenty info build entity's key. so, if entity has ancestor
, id/name lone insufficient.
if entity has ancestor, can build key , load entity key, this:
key<scores> scorekey = key.create(parentkey, scores.class, playername); ofy().load().key(scorekey).now();
google-app-engine gae-datastore objectify
Comments
Post a Comment