Hello,
I'm encountering the following issue when I'm trying to retrieve several
(11) keys in batch using JDO.
Here are some snippets that are showing what I'm doing.
Parameters: offset: 0, pageSize: 11
1) batch get with containsKey
Iterable<Entity> addressEntities =
preparedQuery.asIterable(FetchOptions.Builder.withOffset(offset).limit(pageSize));
for (Entity entity : addressEntities) {
addressKeys.add(entity.getParent());
}
// after that we have 11 keys in the list
Query addressQuery =
pm.get().newQuery(DeviceAddressEntity.class,":p.contains(key)");
List<DeviceAddressEntity> addresses =
(List<DeviceAddressEntity>)addressQuery.execute(addressKeys);
// ops, we got only 10 records
2) batch get with key == :key
Query addressQuery = pm.get().newQuery(DeviceAddressEntity.class,"key ==
:keys");
List<DeviceAddressEntity> addresses = (List<DeviceAddressEntity>)
addressQuery.execute(addressKeys);
// ops, we got only 10 records
3) "batch" get by iterating over keys
List<DeviceAddressEntity> addresses = new ArrayList<DeviceAddressEntity>
(addressKeys.size());
for (Key key : addressKeys) {
DeviceAddressEntity address =
pm.get().getObjectById(DeviceAddressEntity.class,key);
addresses.add(address);
}
// yeah, we got exactly 11 records
The strange part is that all 3 ways are working correctly on my unit
test environment and only "3)" is working correctly when code is
deployed in the cloud or in GAE's local server.
Here is my test that is testing the following functionality:
@Test
public void findAddressesByUsingOffsetAndPageSize() {
Iterable<DeviceAddressEntity> addresses = generateOrderedAddresses(12);
saveAllAddresses(addresses);
List<DeviceAddressEntity> actualSearchResult =
service.findAddresses(0,11,"");
assertEquals("actual address count was different from
expected?",11, actualSearchResult.size());
}
Any idea what is causing the following issue?
As I remember, that part of my code (1 snippet) was working correctly on
GAE 1.3.3.
Regards,
Miroslav
--
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.