I would have used an meaninless ID if I could, my problem is that I'm making an distributed solution, where the object is saved on the client and then uploaded to an central server.
In the first scenario when the object is saved on the client all works fine, but when I want to upload it to the server and save it on the serves database its already has an ID given to it from the first save on the client. I have evaluated an approach where I have ServerId and ClientId, but I do not really like that approach either, I will look at Session.Persist. It would be nice though you will never implement select to check if already saved in db and then use insert or update depending on the result given from the check, but can I somehow jack in that functionality easy? But as you know, I don't like this approach either. What would you do in my scenario? On 22 Juni, 23:57, Fabio Maulo <[email protected]> wrote: > Ah... Niclas...If you are using Identity, as POID generator, take care with > session.Persist because this is only another part of the never ending story > (what mean "find the ID" when Identity is used as strategy ?). > > 2009/6/22 Fabio Maulo <[email protected]> > > > > > 2009/6/22 Niclas Pehrsson <[email protected]> > > >> 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. > > > Forget it! > > You can force NH to do a select before update (by mapping) you can use the > > unsaved-value (by mapping) but you can pretty sure we will never implements > > a select before insert only to check if an id exist. > > The POID (Persistent object ID), when you choose "assigned", is under your > > resposibility. > > > 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. > > > Use a no business meaning POID an let NH or the DB generate it. > > If the problem is only because you need all ID when you save the root > > entity you can use session.Persist. > > -- > > Fabio Maulo > > -- > 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 -~----------~----~----~----~------~----~------~--~---
