开发者

web application architecture using nhibernate

hi I'm designing my first asp.net web app, using nHibernate as the data provider.

i've read a lot about nhibernate in web applications using session-per-request pattern. my application will have a few pages which are 'monitors', meaning- they're updated automatically every few seconds to reflect recent changes to data. in that case, my thought is that opening a session for every request would not make much sense, since I know that an identical request is sure to follow in a few seconds.

my thought is that session-per-conversation would make more sense for me, but I'm having trouble finding examples of implementations. I'd appreciate any good resources for how to implement se开发者_如何学JAVAssion-per-conversation, and any other ideas / suggestions you may have.

thanks

Jhonny


A session-per-request is still a good idea, as you don't know, in a web-scenerio, when a conversation ends. There's not much overhead to opening/closing a session, and the connection is only kept open whilst the session is in a transaction. , and, as a session wraps a database connection, you're simply using up connections from the connection pool by keeping your sessions open.

if you're stuck on a session-per-conversation stuff, look at NHibernate.Burrow - this handles all the conversation/session management stuff for you.


If you were to use session-per-conversation, it seems to me that for the monitor pages the conversation would be ongoing during the entire user session. I would not recommend that approach because there are so many opportunities for problems in that scenario. I would recommend opening an IStatelessSession to update the monitor data display because that gives you the benefit of short-lived sessions without having the overhead of tracking object state.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜