我有这种情况:
我从服务器收到此错误:
com.google.api.server.spi.SystemService invokeServiceMethod: null java.lang.NullPointerException at com.google.appengine.api.datastore.Key.getAppId(Key.java:279) at com.google.appengine.api.datastore.KeyTranslator.convertToPb(KeyTranslator.java:50) at com.google.appengine.api.datastore.EntityTranslator.convertToPb(EntityTranslator.java:48) at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$4.toPb(AsyncDatastoreServiceImpl.java:178) at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$4.toPb(AsyncDatastoreServiceImpl.java:155) at com.google.appengine.api.datastore.Batcher$BatchIterator.(Batcher.java:180) at com.google.appengine.api.datastore.Batcher$2.(Batcher.java:317) at com.google.appengine.api.datastore.Batcher.getBatches(Batcher.java:317) at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.doBatchPut(AsyncDatastoreServiceImpl.java:365) at com.google.appengine.api.datastore.BaseAsyncDatastoreServiceImpl.put(BaseAsyncDatastoreServiceImpl.java:293) at com.google.appengine.api.datastore.BaseAsyncDatastoreServiceImpl.put(BaseAsyncDatastoreServiceImpl.java:239) at com.google.appengine.api.datastore.DatastoreServiceImpl.put(DatastoreServiceImpl.java:61) at com.google.appengine.datanucleus.WrappedDatastoreService.put(WrappedDatastoreService.java:112) at com.google.appengine.datanucleus.EntityUtils.putEntitiesIntoDatastore(EntityUtils.java:766) at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObjectsInternal(DatastorePersistenceHandler.java:314) at com.google.appengine.datanucleus.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:218) at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:2381) at org.datanucleus.state.JDOStateManager.flush(JDOStateManager.java:3778) at org.datanucleus.ObjectManagerImpl.flushInternalWithOrdering(ObjectManagerImpl.java:3888) at org.datanucleus.ObjectManagerImpl.flushInternal(ObjectManagerImpl.java:3811) at org.datanucleus.ObjectManagerImpl.flush(ObjectManagerImpl.java:3751) at org.datanucleus.ObjectManagerImpl.preCommit(ObjectManagerImpl.java:4141) at org.datanucleus.ObjectManagerImpl.transactionPreCommit(ObjectManagerImpl.java:428) at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:398) at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:287) at org.datanucleus.ObjectManagerImpl.close(ObjectManagerImpl.java:1090) at org.datanucleus.api.jpa.JPAEntityManager.close(JPAEntityManager.java:193)
它不是从数据存储中检索的同一对象吗?
答案 0 :(得分:1)
您可以将主键转换为
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
如果您正在使用
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
再次检查。