These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Refreshing the first session cache?
PostPosted: Mon Oct 16, 2006 10:13 am 
Newbie

Joined: Thu Jun 29, 2006 11:49 am
Posts: 13
Hello.

We are begginning to use recently nhibernate for accesing data. At the moment we feel very confident with it, but we have been fighting with one problem that is still giving us some pain: the FIRST SESSION CACHE.

As I know (and read from your documentation) when I kill a session the cache is cleared, nevertheless in some cases the cache does not seem to clear, and still gives me obsolete objects.

We are killing the session using this code:
// private static ISession oSession
if (oSession != null)
oSession.Clear();

We have no second cache declaration in our .config files.

Are we doing something wrong? Any better idea for "killing" the cache?

How do people usually work with nhibernate in the usual scenario?:

a) USER1 connects.
b) USER2 insert/updates a field of an object that is seeing the USER1.
c) How does USER1 refreshes the data of the object modified by USER2 if it is using a different Session object?

Thanks in advance.

Regards,

Andrés [ knocte ]

--


Top
 Profile  
 
 Post subject: Objects not being refreshed on Query execution
PostPosted: Tue Oct 17, 2006 5:17 pm 
Newbie

Joined: Tue Mar 21, 2006 3:11 pm
Posts: 10
I am having a similar problem. In my 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 once a minute, but updates aren't being reflected in the objects returned from query.

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.

Below is the snippet of code I am executing. So, what am I doing wrong?

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.SetCacheRegion("CreditApplicationDAO.FindAllActiveApps")
      .SetCacheable(false)
      .SetForceCacheRefresh(true)
                 ;

   IList apps = q.List();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.