google app engine - On GoogleEngine (Java), in JDO, how do I query a list of child objects based on the id of the parent? -
i have 2 value objects, calendar , event, persistent. calendar has property consists in list of events, 1 many relationship. calendar parent of events shown below.
@persistent @element(dependent = "true") private list<event> events;
now, able retrieve via jdo query, events corresponding calendar, based on calendar object key. using encodedkey both classes.
i want run query on event entity , not retrieve whole calendar object, because want able retrieve set of events, pagination purposes.
i tried in possible way, not figure out how query parent key.
any appreciated.
a few notes:
list properties in entities (like list<event> events
) stored serialized protocolbuffer. problem is:
if property indexed, limited 5000 elements.
every time query list, whole list needs deserialized. answer question if can selectively retrieve list elements: can't.
if have multiple indexed list properties in entity can lead exploding indexes.
if want understand internals of gae datastore vido must: http://www.youtube.com/watch?v=agal6ngpkb8
solutions:
use solution slatkin's video: make calendar parent (in datastore terms) of event. add parent condition query:
query.setancestor(key calendarkey)
.update: entity parent relationship should used create "entity groups", e.g. unit on transactions scoped.
reverse situation: create event entity has calendar property points calendar event belongs. can query events have 'calendar == calendarkey`.
Comments
Post a Comment