开发者

Problem deleting an entity which has a dependent "Set" Entity

I have a "Parent" entity which has a Set of "Child" entities, as follows:

class Parent {

@Persistent @Element(dependent = "true")
private Set<Child> children;

}

When I delete the "Parent" entity I get the following exception:

javax.jdo.JDOUserException: Cannot read fields from a deleted object
FailedObject:com.google.appengine.api.datastore.Key:Parent("1000345345456567676")/Child(2)

It seems JDO deletes the "Parent" entity before the "Child" objects in the dependent Set property, which causes the above exception to appear when the Child entities in the Set are themselves deleted. Does anyone know how to solve this issue?

FYI when I delete the parent 开发者_如何学运维entity I use pm.deletePersistent() within a transaction.

Thanks


Could it be that you are simply calling pm.deletePersistent(objectFoo) and then later on in the code calling pm.makePersistent(objectFoo). I was doing this and getting the above error message. Regards, John Goche


If this does not fix it there is another solution. If you are using eclipse do a Refactor -> Rename on your class and rerun your code. This should get rid of stale information in the datastore and let you start from scratch without the problem. Regards, John Goche

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜