Fabio, thank you very much for your reply. 1. Do you know why it does return the id when you perform a SAVE directly on the child (_traffcLineDao.Save(newTrafficLine);)? 2. Why does it work differently than the SaveOrUpdate on the parent? 3. Is there a post somewhere that explains this i depth that you know of?
I would imagine that it should be very common to retrieve the ids right away after an object is persisted (i.e. before the session is finally flushed), like when lists are returned, so that when a user clicks on a specific listed item it will have the id already in it so that the server knows which child was selected. This is especially true when you look at the suggestions from the NHibernate docs where ids are recommended rather than natural keys, as in many cases like list of addresses, etc, it is not possible to identify a unique address by its content/natural keys (for example 100 Main Street is the same as Main Street No 100). 4. I would like to understand how the different persistence options work, pros and cons so I can make an informed decision on which one to use. On Dec 8, 8:18 am, "Fabio Maulo" <[EMAIL PROTECTED]> wrote: > 2008/12/8 Renso <[EMAIL PROTECTED]> > > > > > Why does it not perform the select to retrieve the newly generated id > > when I SaveOrUpdate on the parent (product line)? > > Because NH delay the DB access as late as possible.If you really need the ID > and you want force the DB access you have two choice: > 1) Flush the session > 2) Use session.Persist instead SaveOrUpdate (... if I well remember the > Persist behavior). > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
