Hello,
I have a business entity named ChargeActivity, and I am not using second level caching nor am I using query caching. I fetch an object of ChargeActivity as
Ilist result = _session.CreateQuery(Predicate).SetCacheable(false).List();
No I go the database an fire a query and change one of the column against charge activty and now I again call
Ilist result = _session.CreateQuery(Predicate).SetCacheable(false).List();
unfortunately I don't get the updates. But I see that NHibernate fires query to the database.
In file Loader.cs , there is one method as
DoQuery(ISessionImplementor session,QueryParameters queryParameters,bool returnProxies)
In this methods there is one statement as
IDataReader rs = GetResultSet(st, selection, session);
Which actualy fires the query and gets the updated result in variable rs.
But further there is call to method GetRowFromResultSet which in turn calls method GetRow, and in method GetRow
it checks whether the object already exists in the cache(first level) and returns if found, therefore updates are not available
obj = session.GetEntity(key);
if (obj != null)
{
//its already loaded so dont need to hydrate it
InstanceAlreadyLoaded(rs, i, persisters[i], key, obj, lockModes[i], session);
}
else
{
obj = InstanceNotYetLoaded(rs, i, persisters[i], key, lockModes[i], optionalObjectKey, optionalObject, hydratedObjects,session);
}
return obj;
Why does it fire query to database and also check whether the object is in local cache? Also even if the object exists in the local cache it is not updated with the result set newly fetched from the database.
Can someone please help?
|