I'm now thinking that instead of using detachable="false", set it to true so that it can be easily updated. To create new unparented objects, use a constructor that takes a "template" object you got from the data store;
Department fetchedDepartment = departmentDao.findById(id); Department addedDepartment = new Department(fetchedDepartment); person.addDepartment(addedDepartment); personDao.makePersistent(person); The constructor copies stuff that stays the same and sets up whatever else needs setting up. James H wrote: > I'll listen to the video today. Right, I agree with your "natural > key" philosophy Rusty. So, a regular auto-generated type of Key would > always fit the bill. The only use of Encoded Key would be when you > need to construct the key before the actual Insert occurs. I guess > that's the exception and I only ever see that as a requirement for > tasks like "batch" loads, not transactions from a UI. > > On Nov 5, 2:19 am, Rusty Wright <rwright.li...@gmail.com> wrote: >> I'm of the school of thought that says natural keys are never a good idea. >> Whatever natural key you're thinking of using, just make it a "property" on >> the class. One of the things they keep saying is that storage is >> free/cheap, so don't worry about that. Using your example, if you were to >> use the email address as part of the key, how would you be able to search on >> the email address since it would be embedded and encoded in the key? >> >> >> >> James H wrote: >>> Bryce, double-check me on my Nov 4, 1:45pm post. >>> Bryce/Rusty, I'm getting the sense that if I don't need a natural key >>> like email address then I should just use plain Key as the type and >>> let GAE generate the full value including parent key for entity group >>> objects. Otherwise, if I choose to use a natural key like an email >>> address then I would use the encoded Key. Regardless of approach, the >>> type Key can be converted to/from String using keyToString() and >>> stringToKey() for stuffing into html form hidden fields, etc. >>> Rusty, I skimmed the blog but it was too deep for me at this >>> hour...I'll try again tomorrow! >>> On Nov 4, 11:39 pm, bryce cottam <bcot...@gmail.com> wrote: >>>> Yeah, I've been re-considering my detachable="true" configuration and >>>> thinking that i may want to go for detachable="false" for gwt reasons. >>>> Using detachable="true" creates a field that is of type Object[] >>>> (which makes the gwt RPC raise fits). >>>> Currently, I find that having the actual Key object is handy (for >>>> getting the type, any parent key references etc.) but that is mainly >>>> stuff I do on the server side, so the client could probably live just >>>> fine and dandy with an encoded String. >>>> On Wed, Nov 4, 2009 at 9:10 PM, Rusty Wright <rwright.li...@gmail.com> >>>> wrote: >>>>> Did you see this? This article has been referenced a couple of times >>>>> today: >>>>> http://timepedia.blogspot.com/2009/04/google-appengine-and-gwt-now-ma... >>>>> The part about using detachable = "false" is interesting. >>>>> James H wrote: >>>>>> Datanucleus, both suggestions worked but I like the "embeddedOnly" >>>>>> best in order to avoid a dummy key on every FK class! >>>>>> Bryce, I no longer get the error above...I just added >>>>>> embeddedOnly="true" to the PersistanceCapable tag in BookFk class. >>>>>> You're right, I could use the collection technique on the FKs but I >>>>>> wonder the pros/cons of such collections on what could be very large >>>>>> collections. For example, say Baylor with 25,000 members? Guess its >>>>>> a matter of using "owned" for small Sets versus "unowned" for large >>>>>> Sets of data. Regardless, your FK pattern will save a whole lot of >>>>>> code management!!! >>>>>> Any further feedback welcome...I'll continue testing! >>>>>> On Nov 4, 12:12 pm, datanucleus <andy_jeffer...@yahoo.com> wrote: >>>>>>>> Needs a PK either way. Pick a field, any field. >>>>>>> Or just set "embeddedOnly" as true ... if you really never want to >>>>>>> persist one of those in its own right- Hide quoted text - >>>> - Show quoted text -- 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 google-appengine-java@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 -~----------~----~----~----~------~----~------~--~---