I have three Classes (User, Person, Company) that are all subclasses
of BaseClass.
Company has a list of employees<Person>
Person may have a user<User>
@PersistenceCapable(detachable="true")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class BaseObject {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Key id;
}
@PersistenceCapable(detachable="true")
public class Company extends BaseObject {
@Persistent(mappedBy = "employer")
@Order(extensions = @Extension(vendorName="datanucleus", key="list-
ordering", value="lastName asc, firstName asc"))
List<Person> employees;
}
@PersistenceCapable(detachable="true")
public class Person extends BaseObject {
@Persistent
Company employer;
// @Persistent(mappedBy = "person")
// User user;
}
@PersistenceCapable(detachable="true")
public class User extends BaseObject {
@Persistent
Person person;
}
Now I can create a company, persist it, then create a person, set its
employer, and persist it. But I cannot create a user and set its
person. GAE thinks that I am trying to make User the parent of
person, but it actually the other way around.
"Detected attempt to establish User(7) as the parent of Company(5)/
Person(6) but the entity identified by Company(5)/Person(6) is already
a child of Company(5)."
I had to comment out the User back reference in Person since with it,
GAE things that Person has more than one parent. This is odd as well,
but I can live without it if i have to. I am just trying to avoid
doing this with not-owned relationship between user and person.
what am i doing wrong? or is this just a bug?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-java?hl=en.