Re: [appengine-java] Many to many relation ship

2010-10-19 Thread John Patterson
On 7 October 2010 05:15, hadf hadrien.for...@gmail.com wrote:

  how jpa or jdo knows that Car is associated to User ?

 public class Car {
@OneToMany
private SetKey users; //this relation ship is untyped
 }


Two alternative datastore frameworks add typing in different ways.  Twig
uses direct references:

class Car
{
  SetUser users;
}

and Objectify uses generic Keys;

class Car
{
  SetKeyUser users;
}

http://code.google.com/p/twig-persist/
http://code.google.com/p/objectify-appengine/

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



[appengine-java] Many to many relation ship

2010-10-06 Thread hadf
Hello,

I read that many to many relation ship must resolved by using sets of
Key.
But what I don't understand is how do I specify the type the Key is
referencing.
I mean that if I have a many to many relation ship between Car and
User, how jpa or jdo knows that Car is associated to User ?

public class Car {
@OneToMany
private SetKey users; //this relation ship is untyped
}

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



Re: [appengine-java] Many to many relation ship

2010-10-06 Thread andy stevko
Not sure why the datastore needs to know that a Car is associated with a
particular User.
There is no easy way for the datastore to handle cascading deletes in a
M-to-M relationship w/o reference counting.
Also setting the Fetch policy to load children with the parent load is not
an option due to them being in separate entity groups.

Regardless, you can use
 
*getObjectByIdhttp://db.apache.org/jdo/api23/apidocs/javax/jdo/PersistenceManager.html#getObjectById%28java.lang.Class,%20java.lang.Object%29
*(java.lang.ClassT cls, java.lang.Object key)

to verify the Key is referencing a particular class and an object exists.


On Wed, Oct 6, 2010 at 2:15 PM, hadf hadrien.for...@gmail.com wrote:

 Hello,

 I read that many to many relation ship must resolved by using sets of
 Key.
 But what I don't understand is how do I specify the type the Key is
 referencing.
 I mean that if I have a many to many relation ship between Car and
 User, how jpa or jdo knows that Car is associated to User ?

 public class Car {
@OneToMany
private SetKey users; //this relation ship is untyped
 }

 --
 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 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 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.