I am using JDO and google app engine. I have User class which has an arrayList of area objects. Every area object has an arrayList of Location objects which tells about coordinates. Now i want to move one area object from one user to other. I am making clone object of the area object which i want to move and put that in other user's areaList. And then remove that area from 1st user's list by using remove(index). But its giving this error:
Detected attempt to establish User("arash") as the parent of User("mh")/RunData(153) but the entity identified by User("mh")/RunData(153) is already a child of User("mh"). A parent cannot be established or changed once an object has been persisted.
Whe开发者_开发技巧re arash and mh are the users and i am moving area from mh to arash.
Thanks in advance.
How can i solve this problem. Thanks in advance.
As you give no information on how you coded those classes the will be no code that I can give you as a silver bullet. But there could be! So here are some words :-)
The issue is that App engine datastore keeps reference to the parent of the object in the key or ID (what ever you call it). And as good any good framework it checks that you do not do something that you did. :-) Hence the message.
When you cloned "object of the area object" you cloned its ID or Key too. Right? That is the problem. You must give it a new Key or ID. This is the point where I could give you some code but you gave little info so you will have to go to the KeyFactory JavaDoc your self.
Good Luck!
精彩评论