Like Oskar said, NHibernate does not repopulate entities from the database unless a Refresh is called. The problem can be described as:
1 - In a session, you load some entity(ies) from the database, using Get, QueryOver, Query, or whatever; 2 - Some of the records that are mapped to the entity(ies) change in the database; 3 - In the same session, if you load the entity(ies) again, using whatever API you want, the changed columns are not mapped to the already loaded entity(ies). You have at least 3 choices: 1 - Evict the entities from the session, by calling ISession.Evict() or ISession.Clear(); 2 - Use a stateless session, which doesn't have a first level cache, so does not keep track of loaded entities; 3 - Manually call ISession.Refresh() on each loaded entity to get updated values from the database. RP On Monday, May 27, 2013 10:15:38 AM UTC+1, Atilla İlhan KARTAL wrote: > > We are using the code snippet below: > > Session.QueryOver<M>().Where(expression).List<M>(); > > Is this reloading objects or do we need to use something else? > > Thank you for your help in advance. > > Best Regards, > > > 2013/5/27 Oskar Berggren <[email protected] <javascript:>> > >> Are you also actually reloading the objects? NHibernate will typically >> not modify your existing objects once they are loaded. >> >> /Oskar >> >> >> 2013/5/26 Atilla İlhan KARTAL <[email protected] <javascript:>> >> >>> Dear All; >>> >>> We are working with nhibernate on a winform project. We are using a grid >>> to list objects. When we try to run application on two different computers, >>> the grid doesn't refresh values. When a user changes something on the list, >>> even if the other user refreshes the grid, it doesn't show the updated >>> values. The database is updating, though. >>> >>> We tried Session.Clear(), Session.Evict(), >>> Session.SessionFactory.Evict(typeof(object)), >>> Session.QueryOver().CacheMode(Refresh / Ignore)... But none of them seems >>> to be working. We are getting lazy load exceptions. What can we do about it? >>> >>> Thank you for your help in advance. >>> >>> Best Regards, >>> >>> -- >>> Atilla İlhan KARTAL >>> Web Application & Software Architect >>> (Java & PHP & Registered Android Developer) >>> Kuşadası / Aydın / Turkey >>> www.atillailhankartal.com.tr >>> twitter.com/TrojanMyth >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "nhusers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> To post to this group, send email to [email protected]<javascript:> >>> . >>> Visit this group at http://groups.google.com/group/nhusers?hl=en-US. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> Visit this group at http://groups.google.com/group/nhusers?hl=en-US. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Atilla İlhan KARTAL > Web Application & Software Architect > (Java & PHP & Registered Android Developer) > Kuşadası / Aydın / Turkey > www.atillailhankartal.com.tr > twitter.com/TrojanMyth > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
