views:

149

answers:

1

I'm with app engine and using the java low level api, and I want to retrieve a group of entities having its ids. What's the way to do so? I could fetch one by one but there must be a better way.

Thanks!

+1  A: 

I think you're looking for this method, specifically in the following overload:

java.util.Map<Key,Entity> get(java.lang.Iterable<Key> keys)

to which you pass any iterable collection of Keys and get back a map from those keys (more precisely, the subset of those keys that do correspond to entities) onto the corresponding entities. (To make a Key from an id you use a KeyFactory -- various createKey overloads, depending on parent or no parent). Back to get, there's a transactional overload for it too, if you do need to work in a transaction.

Alex Martelli