Hi, I think that the performance of List<Picture> can actually be better then using List<Key>. Of course you should not try to retrieve the pictures by using user.getPictures() if there are many, because it will try to load all of them. But the difference is how it is stored in the database. I think the values of List<Key> are stored as a list attribute of the User entity (which might have some limitations regarding size), while in the case of List<Picture> the relationship between the User and Picture is established by defining the User entity as the parent of the Picture entities. The latter allows you to retrieve an arbitary subset of the pictures (or only their keys) by using queries, while the former will load all keys when you get the value of the collection attribute.
But, if you are having a lot of pictures per user then the List<Picture> attribute will be useless, anyway. You should rather assign the parent of the pictures yourself (by constructing a key or using the "gae.parent-pk" extension). Or if you do not need the pictures to be in the same entity group as the parent, then you can just create a Key (or other identifier) attribute that contains the id of the user that the picture belongs to. Marton On Sep 24, 3:05 am, objectuser <[email protected]> wrote: > Well, yeah, it depends on the questions you want to ask the datastore > and what you're going to do with that data. If your list is large, do > you always want to fetch the whole thing together anyway? Then an > owned relationship might be fine (but note the entity fetch limit). > > Do you want to fetch things in smaller pieces? Then the model > recommended by Ieszek is probably going to serve you better. > > I recommend reading about entities and entity groups and then the > articles about performance and modeling. There's a lot there that's > relevant. > > On Sep 22, 8:00 am, Andreas Kristensson > > <[email protected]> wrote: > > My thinking as well. > > > However, looking at GAE Java examples, tutorials, articles, etc, it's > > often the other way around - i.e. keeping lists with referenced > > objects... Might be that those examples outline one-to-few > > relationships where it's (for some reason?! simpler?!) ok to have > > lists of referenced objects instead of lists of keys to referenced > > objects. > > > On Sep 22, 2:46 pm, leszek <[email protected]> wrote: > > > > Much better is to keep List<Key> than retrieve Pictures on demand > > > ('paging' them) using 'batch gets' : > > > >http://groups.google.co.uk/group/google-appengine-java/browse_frm/thr... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---
