session.Persist 2009/6/22 Niclas Pehrsson <pehrs...@gmail.com>
> > Hi I have earlier posted here about I had the problem with saving an > Parent Child scenario when the Id's already had been given to the > Parent and Child during some circumstances. > > I have tried the Save method but it only tries to "Save" the top > object in the object graph and not the children, there it seems like > it try to use SaveOrUpdate method anyway and it gives me an > StaleException, I would rather avoid using > > session.Save(rootObject); > foreach(var child in rootObject.Childs) > { > session.Save(child); > } > > My question is if I can get NHibernate to check with an select query > before any new insert or update if there exist any row/object with the > given Id and depending on the answer uses insert or update. > > I know this is an really ugly solution if you look at performance > cause one insert gives one select and gives us N^2 selects but I like > it more than using the code everywhere so I can save the rootObject > more "atomic". > > Any other solutions are welcome. > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---