使用一个过滤器进行简单查询:
PersistenceManager pm = PMF.getFactory().getPersistenceManager();
Key userKey = KeyFactory.createKey(User.class.getSimpleName(), Long.parseLong(userId));
Query query = pm.newQuery(Car.class);
query.setFilter("owner == ownerParam");
query.declareParameters(Key.class.getName() + " ownerParam");
List<Car> cars = (List<Car>) query.execute(userKey);
我们收到以下错误(超过约300个条目时)
引起:com.google.apphosting.api.ApiProxy $ UnknownException:API请求datastore_v3.Next()发生错误。 在com.google.net.rpc3.client.RpcStub $ RpcCallbackDispatcher $ 1.runInContext(RpcStub.java:784) 在com.google.tracing.TraceContext $ TraceContextRunnable $ 1.run(TraceContext.java:487) 在com.google.tracing.TraceContext.runInContext(TraceContext.java:774) 在com.google.tracing.TraceContext $ DoInTraceContext.runInContext(TraceContext.java:751) 在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342) 在com.google.tracing.TraceContext $ AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334) 在com.google.tracing.TraceContext $ TraceContextRunnable.run(TraceContext.java:484) 在com.google.net.rpc3.client.RpcStub $ RpcCallbackDispatcher.rpcFinished(RpcStub.java:824) 在com.google.net.rpc3.client.RpcStub $ RpcCallbackDispatcher.failure(RpcStub.java:815) 在com.google.net.rpc3.impl.client.RpcClientInternalContext.runCallbacks(RpcClientInternalContext.java:953) 在com.google.net.rpc3.impl.client.RpcClientInternalContext.finishRpcAndNotifyApp(RpcClientInternalContext.java:856) 在com.google.net.rpc3.impl.client.RpcNetChannel.afterFinishingActiveRpc(RpcNetChannel.java:1195) 在com.google.net.rpc3.impl.client.RpcNetChannel.finishRpc(RpcNetChannel.java:1031) 在com.google.net.rpc3.impl.client.RpcNetChannel.handleResponse(RpcNetChannel.java:2520) 在com.google.net.rpc3.impl.client.RpcNetChannel.messageReceived(RpcNetChannel.java:2277) 在com.google.net.rpc3.impl.client.RpcNetChannel.access $ 2000(RpcNetChannel.java:155) 在com.google.net.rpc3.impl.client.RpcNetChannel $ TransportCallback.receivedMessage(RpcNetChannel.java:3400) 在com.google.net.rpc3.impl.client.RpcChannelTransportData $ TransportCallback.receivedMessage(RpcChannelTransportData.java:626) 在com.google.net.rpc3.impl.wire.RpcBaseTransport.receivedMessage(RpcBaseTransport.java:430) 在com.google.net.eventmanager.AbstractFutureTask $ Sync.innerRun(AbstractFutureTask.java:260) 在com.google.net.eventmanager.AbstractFutureTask.run(AbstractFutureTask.java:121) 在com.google.net.eventmanager.EventManagerImpl.runTask(EventManagerImpl.java:578) 在com.google.net.eventmanager.EventManagerImpl.internalRunWorkerLoop(EventManagerImpl.java:993) 在com.google.net.eventmanager.EventManagerImpl.runWorkerLoop(EventManagerImpl.java:875) 在com.google.net.eventmanager.WorkerThreadInfo.runWorkerLoop(WorkerThreadInfo.java:160) 在com.google.net.eventmanager.EventManagerImpl $ WorkerThread.run(EventManagerImpl.java:1846)