-->
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.  [ 4 posts ] 
Author Message
 Post subject: Stale session cache even when using versioning
PostPosted: Thu Feb 11, 2010 1:42 am 
Newbie

Joined: Mon Sep 01, 2008 6:31 am
Posts: 11
Location: Zwolle, The Netherlands
Have a setup with NHibernate 2.1 and mapped classes that all implement versioning. When getting an object from the session (using get) it would normally return the version in the session cache if it exists or otherwise check the second level cache for the data from which to construct a new instance (which then ends up in the session cache). By calling session.Refresh(o, LockMode.Read) you can force the refresh to bypass the caches and get the absolute up to date information on the object.

My question is this, I have loaded a great number of objects in the session to display several weeks of flying activities (say legs). Then when I change and save a particular flight using another sesssion (or from another computer) I would need to refresh this information. However, when calling the ICriteria query again for the same period, I would see the up to date information for any objects that are newly created in the period, but the existing legs still contain the old information (from the session cache)! Is there a way to force the query to update/refresh the session objects with the latest information when the version has changed, rather than returning the old info? The SQL query that is fired contains the version numbers but somehow that does not trigger a refresh??? So I quess the question is how do I prevent my session cache to get stale (as far as I know you can only set expiration times on 2nd level cache) Now I have to clear the complete session.cache before calling the query again (which seems a bit too dramatic)

_________________
Theo
Nairobi, Kenya


Top
 Profile  
 
 Post subject: Re: Stale session cache even when using versioning
PostPosted: Wed Mar 03, 2010 9:13 am 
Newbie

Joined: Mon Sep 01, 2008 6:31 am
Posts: 11
Location: Zwolle, The Netherlands
It sure is interesting to post things on a forum and not having anyone who has the slightest bit of information on the matter. So I have to assume that either my question is so blatently stupid that nobody bothers to reply, or so badly worded that nobody understands... So can anyone tell me or ask me what wrong assumptions are into play here? Have only been working with NHibernate for a year so cannot claim to be the expert ;-)

_________________
Theo
Nairobi, Kenya


Top
 Profile  
 
 Post subject: Re: Stale session cache even when using versioning
PostPosted: Wed May 26, 2010 9:42 am 
Newbie

Joined: Wed May 26, 2010 9:37 am
Posts: 2
Hi tderoo,
Did you find a solution to this problem ?
Would be very helpfull to me.
Thanks


Top
 Profile  
 
 Post subject: Re: Stale session cache even when using versioning
PostPosted: Sat Jun 19, 2010 4:22 am 
Newbie

Joined: Mon Sep 01, 2008 6:31 am
Posts: 11
Location: Zwolle, The Netherlands
rodolasticot wrote:
Hi tderoo,
Did you find a solution to this problem ?
Would be very helpfull to me.
Thanks


No unfortunately this problem is still occuring. It seems that NHibernate is very much developed with a web interface in mind where you just have a page whith the session at the beginning, make your changes, and save them. Then you just take a new session for the next action. This does not combine very well with the forms approach where multiple screens could be amending the same information over a longer time span. At the moment I start to rely more on the 2nd level cache and sometimes just clear the current session before refreshing even if that feels like a waste of resources. Still waiting for the guru who could tell me a bit more :-) So sorry but no answers yet...

_________________
Theo
Nairobi, Kenya


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.