SELECTING CHILD ENTITIES WITH GQL QUERIES http://ift.tt/1eu2QCh...

Please Visit: http://ift.tt/1ajReyV



SELECTING CHILD ENTITIES WITH GQL QUERIES

http://ift.tt/1eu2RX6

A one-to-many bidirectional relationship is similar to a one-to-one, with a field on the parent class using the annotation @Persistent(mappedBy= "..."), where the value is the name of the field on the child class:

SELECT * FROM Model where _key_ = KEY('Make', 'canon', 'Model', 'canon eos 5d')

Key makeKey = KeyFactory.createKey(Make.class.getSimpleName(), makeName);

// Can create the Model key by specifying parent key...

Key modelKey = KeyFactory.createKey(makeKey, Model.class.getSimpleName(), name);

// Bam! Get the child entity in a single query

Model model = pm.getObjectById(Model.class, modelKey);



You're right. I don't recall really struggling to choose the name “Make” it just seemed like the only option at the time, probably because in EXIF data it is called Make and Model. Now that I look at it, “makeKey” is a pretty stupid variable name, I just never read it in my head in the way ...







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1eu2QCj

via LifeLong Community

No comments:

Post a Comment