Thanks for the reply.

I turned the relationship around and it managed to work, but I still
liked your idea of embedding the user class better since there will be
no user without a person object.

I am still not sure i want to get tied down to GAE, so trying to use
it for now, but stay generic enough to be able to move to another
platform if need be.  There are too many restrictions on doing join
queries.

On Apr 14, 5:35 am, John Patterson <jdpatter...@gmail.com> wrote:
> You might find it easier to use one of the datastore specific  
> persistence interfaces like ObjectDatastore
>
> You could then define a much cleaner data model like:
>
> class Company
> {
>         Collection<Person> employees;
>
> }
>
> class Person
> {
>         @Child User user;  // could use @Embed instead
>
> }
>
> I've left out the super class with the key because normally keys are  
> not needed with the ObjectDatastore... Twig manages those behind the  
> scenes for you.  Perhaps you could embed the user instead - would it  
> normally be loaded at the same time as a Person?
>
> More detailshttp://groups.google.com/group/twig-persist
>
> On 13 Apr 2010, at 23:01, korey_sed wrote:
>
> > 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 google-appengine-java@googlegroups.com
> > .
> > To unsubscribe from this group, send email to 
> > google-appengine-java+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/google-appengine-java?hl=en
> > .

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to