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:

  1. if property indexed, limited 5000 elements.

  2. every time query list, whole list needs deserialized. answer question if can selectively retrieve list elements: can't.

  3. 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:

  1. 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.

  2. reverse situation: create event entity has calendar property points calendar event belongs. can query events have 'calendar == calendarkey`.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -