each user can have many questions. questions can have 1 user. following correct
key questionkey = keyfactory.createkey("questions", userid); entity questionentity = new entity("question", questionkey); questionentity.setproperty("questioncategory", questioncategory); ...
the given usage wrong. question, creating key using kind , userid . implies corresponding entity of kind="questions"
, id=userid
, no parents. wrong , start getting errors once have more 1 question user have same key.
ideally need question entity, declare kind question , parent user follows :
1, if using manually generated id or name question , :
key questionkey = keyfactory.createkey(userkey, "questions", questionidorname);
2, if using app engine's auto generate id, no need create key, instead create entity as:
entity questionentity = new entity("questions", userkey)
here userkey key of user entity
Comments
Post a Comment