Unowned relationships are completely independent from owned relationships (correct me if I'm wrong !). Suppose you have 3 entities A, B and C of the same kind "Folder" and all of them have the same entity group parent P (which is of kind "Folders"). So all these entities belong to the same entity group.
We can define the unowned relationship "parent" between two "Folder". We define this relationship by adding an attribute "parent" of type "Key" to the "Person" class. This unowned relationship is defined between two kind of entities, regardless of whether the entities of this kind are in the same entity group or not. So we can put all the entities A, B and C in the same entity group or in different entity groups. But because I want to operate on A, B and C in the same transaction, I've decided to put them in the same entity group. And my problem is the following : I don't know my entity's keys when I'am creating the object, so it's impossible to make references for example from A to B (i.e fill out the "parent" attribute of entity A with the B's key). It is essential that all this operations occur in the single transaction. On Sep 19, 8:34 pm, Diana Cruise <[email protected]> wrote: > Seems I read you can only perform a Save on a particular Entity once > during a transaction...the 2nd would fail. In my scenario above, A > and B are in different Entity Groups. So, are your designs in > agreement with the Max Ross principle as I have described above? > Obviously, this A, B, C relation would be common to most any app. > > On Sep 19, 12:29 pm, objectuser <[email protected]> wrote: > > > > > Interesting. If they're all in the same entity group, how about you > > save the group without the keys set, then set the keys and save again, > > all in the same transaction? > > > On Sep 19, 11:08 am, mlenormand <[email protected]> wrote: > > > > All the entities we are talking about are in the SAME entity group in > > > order to create/update them in the same transaction. In addition to > > > that, we declare an unowned relationship, using "Key" for example. I > > > want to save all my entities in the same transaction. > > > > On Sep 19, 5:52 pm, objectuser <[email protected]> wrote: > > > > > Because your relationships are unowned (so the objects are in > > > > different entity groups, right?), you wouldn't be able to save them > > > > all in the same transaction anyway. > > > > > So you're right: you'll have to save them, which means multiple > > > > transactions, and if one of them fails you'll have inconsistent data. > > > > > On Sep 19, 8:47 am, mlenormand <[email protected]> wrote: > > > > > > Hi Everybody, > > > > > > Here's my problem with JDO and unowned relationships : > > > > > > I have several entities of the same kind that are organized in a > > > > > hierarchical way, maintained with unowned relationships. > > > > > JDO can generate keys for my entities when they are written to the > > > > > datastore, but with this option, I can't know my entity's keys until > > > > > they are saved to the datastore. If I want to make a reference to an > > > > > entity A from an entity B, it seems to be impossible because at this > > > > > time I don't know A's key, that will be generated when transaction is > > > > > committed. > > > > > > One solution would be to use several transactions, each one would > > > > > persist an entity, but it's not good because I want to persist all the > > > > > entities in the same transaction. > > > > > > I know that defining keys myself could solve the problem, but maybe > > > > > there is an other solution that would be better ? > > > > > > Thank you for your help. And thank you to the GAE team for the > > > > > fantastic work you did !- Hide quoted text - > > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
