Hello again,

Yes, calling Refresh is bad in performance terms, only to be used as last 
resort (IMHO). But if you evict some entity from a session, and you reissue 
a query, you will definitely reload from the database and get "fresh" 
entities.
The problem you mention about calling Clear is very strange. Can you 
reproduce these problems in a unit test, that is, without the 
binding-to-a-grid part?
Where are you keeping the session? How many sessions are there? Are you 
disposing of them?

RP 

On Tuesday, May 28, 2013 9:05:13 AM UTC+1, Atilla İlhan KARTAL wrote:
>
> Dear Recardo;
>
> 1 - Evict the entities from the session, by calling ISession.Evict() or 
> ISession.Clear();
> -- We tried Session.SessionFactory.Evict(typeof(M)); Session.Evict(obj); 
> Session.SessionFactory.EvictEntity(), 
> Session.SessionFactory.EvictCollection(); but dont refresh data..
> -- We tried Session.Clear(), yes object refreshed from database but we got 
> exceptions when lazy loading.  
> 2 - Use a stateless session, which doesn't have a first level cache, so 
> does not keep track of loaded entities;
> -- We need lazy loading but Stateless session does not support this 
> feature. 
> 3 - Manually call ISession.Refresh() on each loaded entity to get updated 
> values from the database.
> -- Did you mean ISession.Refresh() for each list / collection object to 
> run Refresh() method. Isn't this performance issue?
>
>
>
>
> 2013/5/27 Ricardo Peres <[email protected] <javascript:>>
>
>> 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]>
>>>
>>>> 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]>
>>>>
>>>>>  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 nhusers+u...@**googlegroups.com.
>>>>> To post to this group, send email to [email protected].
>>>>>
>>>>> Visit this group at 
>>>>> http://groups.google.com/**group/nhusers?hl=en-US<http://groups.google.com/group/nhusers?hl=en-US>
>>>>> .
>>>>> For more options, visit 
>>>>> https://groups.google.com/**groups/opt_out<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 nhusers+u...@**googlegroups.com.
>>>> To post to this group, send email to [email protected].
>>>>
>>>> Visit this group at 
>>>> http://groups.google.com/**group/nhusers?hl=en-US<http://groups.google.com/group/nhusers?hl=en-US>
>>>> .
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<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] <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.


Reply via email to