拥有的一对多字段无法突然修改--DatastoreRelationFieldManager.checkForParentSwitch中的ClassCastException

时间:2013-02-02 15:34:33

标签: google-app-engine google-cloud-datastore one-to-many jdo

我的网络应用程序突然不允许人们购买我们的产品。我不知道该怎么做。

昨晚我们的一位工程师意外地从拥有的一对多字段(在父类中)删除了@Persistent标记。他上传了这个,而没有将其测试到App Engine服务器。我们收到报告说人们买不到东西,所以我们查看了这些变化,进入并恢复了@Persistent标签。

但现在每次代码尝试修改该字段时,我们都会收到异常

请帮助 - 我不知道该怎么做 - 我们已经添加了@Persistent注释 - 为什么会发生这种异常?

@PersistenceCapable
public class Published {
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @PrimaryKey
    private Long id;

    ...
    // see note about this field above
    @Persistent(defaultFetchGroup = "true", mappedBy = "pub")
    private List<License> licenses;
    ...
}


@PersistenceCapable
public class License {
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @PrimaryKey
    private Key id;
    @Persistent
    private Published pub;
    ...
}

当我创建新的已发布并调用pub.getLicensed().add(new Licensed(...))

时,会发生以下异常
Uncaught exception from servlet
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager.checkForParentSwitch(DatastoreRelationFieldManager.java:203)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager$1.setObjectViaMapping(DatastoreRelationFieldManager.java:134)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager$1.apply(DatastoreRelationFieldManager.java:113)
    at org.datanucleus.store.appengine.DatastoreRelationFieldManager.storeRelations(DatastoreRelationFieldManager.java:82)
    at org.datanucleus.store.appengine.DatastoreFieldManager.storeRelations(DatastoreFieldManager.java:959)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.storeRelations(DatastorePersistenceHandler.java:585)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPostProcess(DatastorePersistenceHandler.java:320)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:272)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:256)
    at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:3185)
    at org.datanucleus.state.JDOStateManagerImpl.makePersistent(JDOStateManagerImpl.java:3161)
    at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1298)
    at org.datanucleus.sco.SCOUtils.validateObjectForWriting(SCOUtils.java:1476)
    at org.datanucleus.store.mapped.scostore.ElementContainerStore.validateElementForWriting(ElementContainerStore.java:380)
    at org.datanucleus.store.mapped.scostore.FKListStore.validateElementForWriting(FKListStore.java:609)
    at org.datanucleus.store.mapped.scostore.FKListStore.internalAdd(FKListStore.java:344)
    at org.datanucleus.store.appengine.DatastoreFKListStore.internalAdd(DatastoreFKListStore.java:146)
    at org.datanucleus.store.mapped.scostore.AbstractListStore.add(AbstractListStore.java:105)
    at org.datanucleus.sco.backed.List.add(List.java:649)
    at (my servlet)

1 个答案:

答案 0 :(得分:0)

看起来App Engine错误阻止我上传代码。一旦GAE赶上并切换到新代码,它一切正常。

为了记录,我不确定修复了什么 - 它可能只是添加@Persistent注释,或者可能已将Published.id更改为Key而是一个Long