Hi, I have question to this article http://ayende.com/Blog/archive/2009/04/30/nhibernate-ndash-the-difference-between-get-load-and-querying-by.aspx, discussion under it is closed, so I am asking here:
How does this play with version optimistic lock? It seems that if I use this lock, Load does query the database as well as Get. It is of course, because NHibernate needs to know the version number. Ayende wrote in the aritcle: "Well, if you know that the value exist in the database, and you don’t want to pay the extra select to have that, but you want to get that value so we can add that reference to an object". I would say that there may be something like Load that is useful when you know that entity with the id exists and when you worked with it last time, it had version number "xy", so you call something like Load<T>(id, version), gets the reference, do your changes, flushes the session and NHibernate will check the version... I am thinking about these thing, because I am doing web application, using session per request and now I am looking for some good solution for this scenario: - user wants to edit some entity - it renders form with the original values of the entity in it - user changes something and sends the form - it updates data and checks the version I am currently using this approach: - when I get the entity from database to render form with it's data, I saves it's version to ASP.NET session. - when he posts the form back, I get the entity using Get<T>(id), check that versions are same and than updates. Does this make sence? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
