-->
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.  [ 8 posts ] 
Author Message
 Post subject: Session Cache
PostPosted: Fri Jan 20, 2006 4:45 pm 
Newbie

Joined: Fri Jan 20, 2006 4:42 pm
Posts: 7
If I decide to use session per request in ASP.NET app in order to enable lazyloading, I endup cached all the objects in Session for the request. Which is not very comfortable. Is there anyway to disable the cache thing? Caching object in the whole request is kindof dangerous.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 6:25 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Why do you feel it is dangerous?


Top
 Profile  
 
 Post subject: Session Cache
PostPosted: Fri Jan 20, 2006 7:02 pm 
Newbie

Joined: Fri Jan 20, 2006 4:42 pm
Posts: 7
If some other user changed the data, but my data is cached in Session, I got bogus data.

It's very common I have more than 2 requests at the same time in an ASP.NET application.

sergey wrote:
Why do you feel it is dangerous?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 21, 2006 6:17 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
But you close the session at the end of the request, so the next request gets the up-to-date data.

Also, that's the whole point of using transactions - transaction isolation property means that you can program as if you were the only one accessing the database at a given time, and in the rare case of a conflict or another problem you roll back the entire transaction and tell the user to try again.


Top
 Profile  
 
 Post subject: Session Cache
PostPosted: Tue Jan 24, 2006 4:36 pm 
Newbie

Joined: Fri Jan 20, 2006 4:42 pm
Posts: 7
But this means in the same request, your data is cached. If you have 2 seperate transactions in one request, your data is in danger.

sergey wrote:
But you close the session at the end of the request, so the next request gets the up-to-date data.

Also, that's the whole point of using transactions - transaction isolation property means that you can program as if you were the only one accessing the database at a given time, and in the rare case of a conflict or another problem you roll back the entire transaction and tell the user to try again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 5:35 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Well, if you often have to process two unrelated transactions in one request, you will have to design your application differently and open two sessions during the request.


Top
 Profile  
 
 Post subject: Session Cache
PostPosted: Tue Jan 24, 2006 5:50 pm 
Newbie

Joined: Fri Jan 20, 2006 4:42 pm
Posts: 7
The real problem is NOT that I have 2 transactions in one session, though it could be the case.

Typically you have 2 phase in a request:

Update Data

Load data and render your page.

The second phase is supposed to pick up the latest data. What about another request updated the data after you updated your data?

The rendering process really should NOT be in the same transaction in your updating process, and a transaction really should NOT be that long.


sergey wrote:
Well, if you often have to process two unrelated transactions in one request, you will have to design your application differently and open two sessions during the request.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 10:18 pm 
Regular
Regular

Joined: Mon May 16, 2005 1:35 am
Posts: 67
You could call the Clear method on the NH session between the update and the select if you wanted to use the same session instance and still have up-to-date data.

Alternatively as Sergey said, you could use two separate NH sessions - one for the update, and one for the select. When using a service layer to serve your UI layer this tends to be the case anyway as NH sessions are usually created and destroyed within each service layer call.


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