My project consists of thousands of audio clips, each submitted by a user 
(kind of like YouTube).

Currently, the Clip entity is as follows

// .... 
  private long userId; 

So userId is the id of the person who made that clip.  Since I want to load 
the User object when I load a record, I take my list of recordings (never 
above 20) and do something like this:

SELECT FROM User s WHERE s.id = userIdOfFirst OR s.id = userIdOfSecond 
OR.....

This works, and I create a Map<Long, User> which now allows me to lookup 
users by ID in my app when displaying data to the user, but is this the most 
efficient way of doing it?  I was looking at storing a private Key user, 
because I know I can't do private User user, but I don't know if replacing 
it with Keys would be a lot more efficient since that long is just a key.

So does that big OR query have any performance implications?  Would I be 
better off doing something like:
List<User> relevantUsers = new LinkedList<User>();
for (Clip clip : allMyClips) {
  relevantUsers.add(em.load(clip.getUserId()));
}

Using the em.load should be really quick because right now the long IS the 
key.

Can someone just fill in these gaps for me on my confusion?


-- 
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-java@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