[appengine-java] Re: Unowned relationship confusion
Just my 2 cents: I was "forced" to use an "unowned relationship" for my application because I had very large objects: My parent object "Journey" contained thousands of "JourneyPoints" in a List element. A call to "makePersistent" constantly hit the 30s deadline. By modeling it as an unowned relationship and distributing the parent key by hand to the JourneyPoints everything was fine again and the performance was very good. -- 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] Re: Unowned relationship confusion
> Okey, I got the answer of, what is "Unowned relationships are not supported" > > In our example it will through exception. > * > javax.persistence.PersistenceException: Detected attempt to establish > User(2) as the parent of Role(1) but the entity identified by Role(1) has > already been persisted without a parent. A parent cannot be established or > changed once an object has been persisted.* > > *Datanucleus* Got it? There is nothing to "get" from my perspective. JDO and JPA define two ways of storing a referenced object :- 1. As an embedded object, by using @Embedded (or the equivalent XML) 2. As a reference (an 'identity'). The user should not need to change anything in their class to do that, and "NoSQL" datastores shouldn't need any special incantations for this. You're simply seeing aspects of standard behaviour that are not implemented in GAE/J's plugin -- 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] Re: Unowned relationship confusion
Okey, I got the answer of, what is "Unowned relationships are not supported" In our example it will through exception. * javax.persistence.PersistenceException: Detected attempt to establish User(2) as the parent of Role(1) but the entity identified by Role(1) has already been persisted without a parent. A parent cannot be established or changed once an object has been persisted.* *Datanucleus* Got it? Now the easiest solution to handle unowned relationships is *use aliases* as explained here http://gae-java-persistence.blogspot.com/2010/02/truth-about-joins.html But don't know why it does not work in my case http://groups.google.com/group/google-appengine-java/browse_thread/thread/aefd4e8b918af4f2 *Max*, can you please explain. I believe most of us don't know that way of managin unowned relation. Please help. On Sat, May 1, 2010 at 10:02 PM, Sudhir Ramanandi wrote: > >How can it possibly identify it as an unowned relationship? You have > >references to real objects so its a real (i.e "owned") relationship. > >You have no references to keys (or object identities). > > Aah, this is the point.. I am talking about. > > - The example I gave earlier is an unowned relationship ryt? > *"Role can exist without user, user can exist without role, but user can > have one or more roles"* > > > > You have references to real objects so its a real (i.e "owned") > relationship. > > If I store real references instead of Keys' does it become *Owned*, and If > I store keys instead of *references* does it become *unowned* !!!. > > Then why would I take the trouble of unowned, I will store real references > for all the relations, and all is well. > > - The question is, *When I must use Keys (unowned) instead of references, > otherwise datastore will not support/handle it and through exception or > whatever.* > > The answer to above question will implicitly explain "What is unowned > relationship" and what is "unowned relationship is not supported"* > > Thanks > SN > > > On Sat, May 1, 2010 at 9:46 PM, datanucleus wrote: > >> > *Google says "unowned relationship is not supported"* >> > What does it mean? *How datastore identify that *it is unowned >> relationship**? >> >> No idea. It's a Google special. It's not part of any spec so it's for >> them to answer. >> >> > In above example, If I implement it as normal relationship, as shown in >> > below code, What will happen?. >> > - Can datastore identify it as unowned relationship and through error? >> >> How can it possibly identify it as an unowned relationship? You have >> references to real objects so its a real (i.e "owned") relationship. >> You have no references to keys (or object identities). >> >> -- >> 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. >> >> > > > -- > Sudhir Ramanandi > http://www.ramanandi.org > -- Sudhir Ramanandi http://www.ramanandi.org -- 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] Re: Unowned relationship confusion
>How can it possibly identify it as an unowned relationship? You have >references to real objects so its a real (i.e "owned") relationship. >You have no references to keys (or object identities). Aah, this is the point.. I am talking about. - The example I gave earlier is an unowned relationship ryt? *"Role can exist without user, user can exist without role, but user can have one or more roles"* > You have references to real objects so its a real (i.e "owned") relationship. If I store real references instead of Keys' does it become *Owned*, and If I store keys instead of *references* does it become *unowned* !!!. Then why would I take the trouble of unowned, I will store real references for all the relations, and all is well. - The question is, *When I must use Keys (unowned) instead of references, otherwise datastore will not support/handle it and through exception or whatever.* The answer to above question will implicitly explain "What is unowned relationship" and what is "unowned relationship is not supported"* Thanks SN On Sat, May 1, 2010 at 9:46 PM, datanucleus wrote: > > *Google says "unowned relationship is not supported"* > > What does it mean? *How datastore identify that *it is unowned > relationship**? > > No idea. It's a Google special. It's not part of any spec so it's for > them to answer. > > > In above example, If I implement it as normal relationship, as shown in > > below code, What will happen?. > > - Can datastore identify it as unowned relationship and through error? > > How can it possibly identify it as an unowned relationship? You have > references to real objects so its a real (i.e "owned") relationship. > You have no references to keys (or object identities). > > -- > 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. > > -- Sudhir Ramanandi http://www.ramanandi.org -- 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] Re: Unowned relationship confusion
> *Google says "unowned relationship is not supported"* > What does it mean? *How datastore identify that *it is unowned > relationship**? No idea. It's a Google special. It's not part of any spec so it's for them to answer. > In above example, If I implement it as normal relationship, as shown in > below code, What will happen?. > - Can datastore identify it as unowned relationship and through error? How can it possibly identify it as an unowned relationship? You have references to real objects so its a real (i.e "owned") relationship. You have no references to keys (or object identities). -- 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] Re: Unowned relationship confusion
Thanks for response, Still it does not answer the question I have (or may be, I din't explain my question well). *Google says "unowned relationship is not supported"* What does it mean? *How datastore identify that *it is unowned relationship**? As per the doc "*Unowned relationship is: where both objects can exist independently of their relationship with one another*" In our example, - User may or may not have a role assigned to it. And a role may or may not have been assigned to any user - Role can be created/deleted independently of user - User can be created/deleted without any role. - **List roles** might be empty in user. In above example, If I implement it as normal relationship, as shown in below code, What will happen?. @Entity public class User extends BaseEntity { @OneToOne(fetch=FetchType.LAZY) private List _roles; } public class Role extends BaseEntity { @Basic String _name; } @Entity @MappedSuperclass public abstract class BaseEntity implements IEntity { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") private String _id; } - Can datastore identify it as unowned relationship and through error? - When *user._roles list is empty* can it support the *save* - Can it support *delete* on user? In simple words, how datastore will handle above relationship? Can I create/delete role and users independent of each other? (user may or may not have any role) and still the relationship will be handled by datastore. Thanks SN On Sat, May 1, 2010 at 9:05 PM, datanucleus wrote: > You will only find "unowned relationships" terminology in Google docs. > This "unowned relationships" in the GAE/J docs is where you have a > field that is a "Key" or a Collection/Map/array of keys. So no *real* > relation, just some implicit relation by that "key". You have to > manage these keys yourself, and you tie your code to GAE/J by using > them. > > JDO/JPA specs do not mention such a thing; they only refer to > relationships ... "owned" relationships ... real relationships. This > is where a persistable class has a field that is of a persistable > type, or a Collection/Map/array of a persistable type. i.e 0-N related > objects. JDO provides managed relationships to keep both sides of a > bidirectional relation consistent (under some circumstances). > > -- > 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. > > -- Sudhir Ramanandi http://www.ramanandi.org -- 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] Re: Unowned relationship confusion
You will only find "unowned relationships" terminology in Google docs. This "unowned relationships" in the GAE/J docs is where you have a field that is a "Key" or a Collection/Map/array of keys. So no *real* relation, just some implicit relation by that "key". You have to manage these keys yourself, and you tie your code to GAE/J by using them. JDO/JPA specs do not mention such a thing; they only refer to relationships ... "owned" relationships ... real relationships. This is where a persistable class has a field that is of a persistable type, or a Collection/Map/array of a persistable type. i.e 0-N related objects. JDO provides managed relationships to keep both sides of a bidirectional relation consistent (under some circumstances). -- 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.