“the class”com.google.appengine.api.datastore.Key“类不可持久化

时间:2011-08-14 14:46:56

标签: google-app-engine jdo

我正在尝试删除给定Key of List的多个实体,即:

List keys = obj.getKeys(); pm.deletePersistentAll(keys);

但是,当我尝试删除实体时,我得到以下异常:

javax.jdo.JDOUserException: One or more instances could not be deleted
at org.datanucleus.jdo.JDOPersistenceManager.deletePersistentAll(JDOPersistenceManager.java:809)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.access$301(DatastoreJDOPersistenceManager.java:39)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$2.call(DatastoreJDOPersistenceManager.java:112)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$2.call(DatastoreJDOPersistenceManager.java:110)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$BatchManagerWrapper.call(DatastoreJDOPersistenceManager.java:125)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager$BatchManagerWrapper.access$200(DatastoreJDOPersistenceManager.java:121)
at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.deletePersistentAll(DatastoreJDOPersistenceManager.java:110)

   NestedThrowablesStackTrace: org.datanucleus.jdo.exceptions.ClassNotPersistenceCapableException: The class "The class "com.google.appengine.api.datastore.Key" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found." is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data for the class is not found.
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:241)

以前有没有人经历过这个?我确保我的课程得到了加强,所有课程都被标记为PersistenceCapable。

由于

2 个答案:

答案 0 :(得分:0)

您只能删除持久对象(传递给pm.deletePersistentAll的内容)。 “密钥”不是持久对象

答案 1 :(得分:0)

要按键删除实体,请尝试

DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
ds.delete(key)