Hi,

my recommendation would be to use List<String> . In your reasoning for
query 2 be aware of the lazy loading that JDO performs in the
background to retrieve the related objects.
Query one and two are similar (if nickname is a field of MyAppUser):
Query q = pm.newQuery(MyAppUser.class);
q.setFilter("userKey == userKeyParam");
q.declareParameters("String userKeyParam");

q.execute(appUserKey);

will give you a list<MyAppUser> of his friends.

Hope this helps,
Fred

On 24 Aug., 12:53, androidDeveloper <stepmas...@googlemail.com> wrote:
> Hi all,
>
> I am trying to model a 1:n relationship between different "myAppUser"
> instances on Google App Engines Datastore. MyAppUser has a reference
> to 0...n other users (friends).
> MyAppUser is currently defined as showed below:
>
> class MyAppUser {
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value =
> "true")
> private String primaryKey;
>
> @Persistent
> private User user
>
> @Persistent
> private List<User> friendsList;  Or alternative private List<String>
> friendsList;
> ...
>
> }
>
> I have two queries:
> Query 1: I want to select all MyAppUsers where a specific User is in
> the friendsList.
> Query 2: I want to get all nicknames of the friends of a specific
> MyAppUser. This can be achieved by getting a MyAppsUser by id and then
> calling for each user user.getNickname().
>
> Question query 1: Is a query with a filter on "List<User> friendsList"
> faster or slower than a query with a filter on "List<String>
> friendsList" or is it equal?
>
> For query 2 I would say that a "List<User> friendsList" is faster,
> because I have direct access to the nicknames. With only the id stored
> in the friendsList, I have to make another query for each friend in
> the list to get his nickname.

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to