The getObjectsById function hasn't been optimized to perform a batch get, so
you're just as well-off issuing multiple calls to getObjectById. If you need
to issue a batch get, you'll need to use the low-level API.

- Jason

On Fri, Oct 16, 2009 at 12:21 AM, Rusty Wright <rwright.li...@gmail.com>wrote:

>
> Here's my code; the first call on the persistence manager, getObjectsById
> (note plural Objects) fails.  But then later down it iterates over the Keys
> and that succeeds.  The log output is below the code.  On the get of
> multiple objects it's blowing up on Key User(10002)/DesiredDate(3006) but
> you can see in the log output that it succeeds when it gets them one by one.
>
>    public Collection<DesiredDate> getDesiredDates(final Collection<String>
> desiredDateIds) {
>        final Set<Key> keys = new HashSet<Key>();
>
>        for (final String eachId : desiredDateIds)
>            keys.add(KeyFactory.stringToKey(eachId));
>
>        try {
>            @SuppressWarnings("unchecked")
>            final Collection<DesiredDate> result =
> getPersistenceManager().getObjectsById(keys);
>
>            return (result);
>        }
>        catch (final Exception e) {
>            this.log.error("desiredDate query failed", e);
>        }
>
>        /*
>         * one or more of the keys is bogus; iterate and fetch
>         * individually.
>         */
>
>        final List<DesiredDate> desiredDates = new ArrayList<DesiredDate>();
>
>        for (final Key eachKey : keys) {
>            this.log.debug("getting: " + eachKey);
>
>            try {
>                final DesiredDate desiredDate =
> getPersistenceManager().getObjectById(DesiredDate.class, eachKey);
>
>                desiredDates.add(desiredDate);
>            }
>            catch (final Exception e) {
>                this.log.error("desiredDate query failed", e);
>                this.log.error("desiredDate not found: " + eachKey);
>            }
>        }
>
>        return (desiredDates);
>    }
>
>
> I 10-16 12:04AM 39.810 [rusty-sandbox/4.337068117851573108].<stdout>:
> ERROR: 07:04:39,805:
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:55):
> desiredDate query failed
> javax.jdo.JDOObjectNotFoundException: No such object
> FailedObject:User(10002)/DesiredDate(3006)
>        at
> org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:323)
>        at
> org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1676)
>        at
> org.datanucleus.jdo.JDOPersistenceManager.getObjectsById(JDOPersistenceManager.java:1700)
>        at
> org.datanucleus.jdo.JDOPersistenceManager.getObjectsById(JDOPersistenceManager.java:1745)
>        at
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:50)
>        at
> com.objecteffects.sample.impl.service.DesiredDateService.deleteDesiredDatesById(DesiredDateService.java:116)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$3.run(Method_.java:164)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:162)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke_(Method_.java:131)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:40)
>        at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>        at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
>        at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>        at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>        at $Proxy12.deleteDesiredDatesById(Unknown Source)
>        at
> com.objecteffects.sample.web.action.ListActionBean.delete(ListActionBean.java:45)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$3.run(Method_.java:164)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:162)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke_(Method_.java:131)
>        at
> com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:40)
>        at
> net.sourceforge.stripes.controller.DispatcherHelper$6.intercept(DispatcherHelper.java:442)
>        at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
>        at
> net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
>        at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
>        at
> net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
>        at
> net.sourceforge.stripes.controller.DispatcherHelper.invokeEventHandler(DispatcherHelper.java:440)
>        at
> net.sourceforge.stripes.controller.DispatcherServlet.invokeEventHandler(DispatcherServlet.java:278)
>        at
> net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:160)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>        at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>        at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
>        at
> net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
>        at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>        at
> com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
>        at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>        at
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
>        at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
>        at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
>        at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>        at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>        at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>        at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>        at
> com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238)
>        at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>        at org.mortbay.jetty.Server.handle(Server.java:313)
>        at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>        at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
>        at
> com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>        at
> com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:139)
>        at
> com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:239)
>        at
> com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5135)
>        at
> com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5133)
>        at
> com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24)
>        at
> com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:363)
>        at com.google.net.rpc.impl.Server$2.run(Server.java:814)
>        at
> com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56)
>        at
> com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:516)
>        at com.google.net.rpc.impl.Server.startRpc(Server.java:769)
>        at com.google.net.rpc.impl.Server.processRequest(Server.java:351)
>        at
> com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:437)
>        at
> com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319)
>        at
> com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290)
>        at
> com.google.net.async.Connection.handleReadEvent(Connection.java:436)
>        at
> com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:762)
>        at
> com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:207)
>        at
> com.google.net.async.EventDispatcher.loop(EventDispatcher.java:101)
>        at
> com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251)
>        at
> com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run(JavaRuntime.java:396)
>        at java.lang.Thread.run(Unknown Source)
>
> I 10-16 12:04AM 39.811 [rusty-sandbox/4.337068117851573108].<stdout>:
> DEBUG: 07:04:39,810:
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:66):
> getting: User(10002)/DesiredDate(3006)
>
> I 10-16 12:04AM 39.918 [rusty-sandbox/4.337068117851573108].<stdout>:
> DEBUG: 07:04:39,917:
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:66):
> getting: User(10002)/DesiredDate(3004)
>
> I 10-16 12:04AM 39.934 [rusty-sandbox/4.337068117851573108].<stdout>:
> DEBUG: 07:04:39,933:
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:66):
> getting: User(10002)/DesiredDate(3005)
>
> I 10-16 12:04AM 39.954 [rusty-sandbox/4.337068117851573108].<stdout>:
> DEBUG: 07:04:39,953:
> com.objecteffects.sample.impl.dao.jdo.DesiredDateDao.getDesiredDates(DesiredDateDao.java:66):
> getting: User(10002)/DesiredDate(4001)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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