In my c# winform application I have a form with a list of tasks that users can work on. When a user begins working one, the row is updated to reflect this. The application tries to refresh the list of tasks once a minute, but updates aren't being reflected in the objects returned from queries in other sessions. So, other users are not seing the fact that a task has been updated by another user (and session).
I have tried using SetCacheable(false) and SetForceCacheRefresh(true) but I still get old copies of the objects.
I get this using both 1.0.2 and 1.2b.
I tried manully evicting the object returned from the prior query and this works for the main object, but dependent objects returned in collections are not. So, I imagine I would need to evict these as well. Doing it this way seems kind of messy though. I know a Session.Clear() could be done, but this seems extreme.
Below is the snippet of code I am executing. So, what am I doing wrong? Is there a better approach that I just missed?
Code:
IQuery q
= session.CreateQuery(
"select ca from CreditApplication ca inner join ca.CreditApplicationStateList currstate "
+ " where currstate.AppState = :appstate "
+ " and currstate.DateTimeStateEntered <= :now and currstate.DateTimeCompleted >= :now "
+ (merchId > 0 ? " and ca.Merchid = :merchid " : "")
);
q.SetDateTime("now", DateTime.Now);
q.SetString("appstate", (state != null && state.Length > 0 ? state : "PROCESSING_TERMINATED"));
if (merchId > 0)
q.SetInt32("merchid", merchId);
q.SetCacheable(false)
.SetForceCacheRefresh(true)
;
IList apps = q.List();
I also tried switching query cache off but this didn't have an effect. I also switched to the prevalence cache and set the expiration to 1 second. This didn't seem to help either.[/code]