I have an object model with a Person class that references several role
classes, e.g. Customer, Partner, Administrator.
Since GAE does not support polymorphism, I am trying to implement the
relationship as an ArrayList of role keys in Person with a Person key in
each of the role classes. It looks like this:
class Person {
@Persistent
private ArrayList<String> roleKeys = new ArrayList<String>();
}
class Administrator implements IRole {
@Persistent
private Key personKey;
}
To create an administrator, I create a Person instance and an Administrator
instance. I want to set the Administrator as a child of the Person instance,
i.e. create a datastore key that uses the Person as a parent, so that both
instances are in the same entity group and can be operated on in the same
transaction. I'm trying to do this, as follows:
Administrator admin = new Administrator();
Key adminKey = KeyFactory.createKey(person.getKey(),
Administrator.class.getSimpleName(), ?);
admin.setKey(adminKey);
The problem is that I cannot find a way to generate a unique key for the
Administrator instance that has the Person instance as its parent, and have
the system generate a unique ID as the key for the Administrator instance
using KeyFactory.createKey(). Is there some other way to do this?
Thank you,
Rick
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.