You will need to use an ObjectDatastore instead of JDO if you want to
use direct references as in your example.
http://code.google.com/p/twig-persist/
If you @Embed Work in User you can retrieve all in a single query
http://code.google.com/p/twig-persist/wiki/Configuration#Storage_Options
On 3 Jun 2010, at 11:46, RAVINDER MAAN wrote:
Thanks Bill
I have experience with hibernate thats why i thought it could be
possible.
On Thu, Jun 3, 2010 at 12:00 AM, Bill Milligan <[email protected]
> wrote:
I believe you're going to have to change this to
class User {
String name;
List <String> workNames; // or List <Long> workIds;
}
class Work {
String name;
String userName; // or Long userId;
}
This is actually you'd design this under the MDA paradigm,
actually. You need to be able to change each independently of the
other. As far as "automatic population", like an ORM would do, I
don't think this is possible. You'll have to do this manually.
Honestly, you won't lose much by doing two queries.
On Wed, Jun 2, 2010 at 2:12 PM, RAVINDER MAAN <[email protected]>
wrote:
Thank you so much for your answer Bill
yes you are rite the way i wrote its many to many
relation.Actually I want relation as below
class User{
Long id;
String username;
List<Work> workList;
}
class Work{
Long id;
String workname;
String username;
}
you can see work class has username and user class too has
username.In both classes primary key is id. I just want to know is
there any way to get workList populated automatically on retrieval
of user object.we can do it with 2 queries easily.we can reteriev
user first then we can retrieve work object with second query.
On Wed, Jun 2, 2010 at 10:35 PM, Bill Milligan <[email protected]
> wrote:
Are you trying one-to-many or many-to-many? By using a third table
it sounds like you're trying to do many-to-many, not one-to-many.
As best I can determine, the only real way to do this in GAE is to
have a User class with a collection of string properties, containing
the list of all Work ids. In this case a bidirectional link would
be probably quite useful, so that a Work could be identified by its
User id.
Here's a scenario: Retrieve User by user id. Then, retrieve all
Works in the list of work ids owned by the User.
Note that this is not true object composition, with a User
containing a List of Collection, but rather an indirect reference.
This pattern is useful in a lot of circumstances where you want to
be able to break up your object model into more modular deployable
applications. On the other hand, I'd hate to be completely boxed in
by this restriction.
I'm just getting started with GAE so I'm very much not an expert.
I'd love to know anybody else's thoughts on the matter.
On Wed, Jun 2, 2010 at 12:10 AM, RAVINDER MAAN <[email protected]>
wrote:
Hello all
can anybody please tell me how to implement simple one many
relation in java.I have user table and work table .Any user can do
many type of works.In user table i have userid but it is not primary
key of the user table.Then i have work table which has workid it is
also not primary key of the table.Normally in relation db we ca make
third table table which contains workid for every userid.What how can
we implement this thing appengine datastore.I want to have collection
all works in user object .can anybody please tell me how to define
this mapping?please note that in userid and workid are not primary
keys in both objects or tables.
Thanks in adavance.
--
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
.
--
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
.
--
Regards,
Ravinder Singh Maan
--
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
.
--
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
.
--
Regards,
Ravinder Singh Maan
--
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
.
--
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.