[appengine-java] Re: getting multiple objects fails

2009-10-19 Thread Rusty Wright

Ok, thanks.


Jason (Google) wrote:
> 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  > 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 getDesiredDates(final
> Collection desiredDateIds) {
>final Set keys = new HashSet();
> 
>for (final String eachId : desiredDateIds)
>keys.add(KeyFactory.stringToKey(eachId));
> 
>try {
>@SuppressWarnings("unchecked")
>final Collection 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 desiredDates = new
> ArrayList();
> 
>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].: 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.

[appengine-java] Re: getting multiple objects fails

2009-10-19 Thread Jason (Google)
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 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 getDesiredDates(final Collection
> desiredDateIds) {
>final Set keys = new HashSet();
>
>for (final String eachId : desiredDateIds)
>keys.add(KeyFactory.stringToKey(eachId));
>
>try {
>@SuppressWarnings("unchecked")
>final Collection 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 desiredDates = new ArrayList();
>
>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].:
> 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.AccessC