Thanks for the reply.

I have thought of this way as well, the problem is that I want to
allow the user to change the value of A.name. In this case I will have
to change all the B.Aname values too, which may by then be thousands
of Bs. This will also force me to put A and B in the same entity group
to be able to change the Bs in the same transaction as A, which I
didn't want because of performance issues mentioned in the
documentation. I have learned since my first post that there are no
joins in JDO, so it seems like the only acceptable way of solving it
(the other one would be to not allow changes in A.name which I don't
want to do). It's a pity since this is a very common type of problem
and without joins there seems to be no good way to solve it..

I would appreciate additional comments if I am missing something..



On Mar 12, 2:39 pm, objectuser <kevin.k.le...@gmail.com> wrote:
> One way to do this would be to duplicate A.name on the associated Bs.
>
> class A {
>   Long id;
>   String name;
>   ...
>
> }
>
> class B {
>   Long id;
>   Long Aid;
>   Long Aname;
>   ...
>
> }
>
> Then you'd be able to do your select on just the B entity group and it
> would work.
>
> On Mar 10, 2:59 am, kattus <g.adjiashv...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have 2 persistent classes:
>
> > 1. class A that has a primary key (Long) and a property called
> > "name" (String).
> > 2. class B that is referencing class A (one to many relationship, each
> > B has one A, but A can belong to many B's)
>
> > I need to retrieve the B's sorted by the "name" property of A. In
> > other words if it was relational database I would make something like
> > this (simplified):
>
> > SELECT * FROM A, B WHERE A.id=B.Aid ORDER BY A.name
>
> > The question is how to make this with JDO. I don't want to make A and
> > B in the same entity group and it seams it is not necessary either, I
> > think using unowned relationships may be a good direction, the help is
> > too basic though:
>
> >http://code.google.com/appengine/docs/java/datastore/relationships.ht...
>
> > The questions are:
>
> > Is it possible to define such a relationship between A and B? If yes
> > how (which annotations)? Do I have to use the Key class in B to
> > reference A?
> > How to use the Google query language to write the correct query?
>
> > Thank you,
> > Gil

-- 
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