No CurrentSessionContext configured (set the property current_session_context_class)

2,432 views
Skip to first unread message

graphicsxp

unread,
Apr 21, 2009, 7:44:53 AM4/21/09
to nhusers
I'm getting this exception:

No CurrentSessionContext configured (set the property
current_session_context_class)

when doing : mySessionFactory.GetCurrentSession();

In my hibernate.cfg.xml I've added the property :

<property name="current_session_context_class">thread</property>

But I still get the exception.... I there something I've missed ?

Thanks

Ken Egozi

unread,
Apr 21, 2009, 8:32:23 AM4/21/09
to nhu...@googlegroups.com
is "thread" a class?

if not, you should either locate or implement a class, that can supply a current context based on thread.

graphicsxp

unread,
Apr 21, 2009, 8:40:48 AM4/21/09
to nhusers
ha yes sorry, I got that from somewhere on the web, but I wasn't sure
what I was doing.

I found that there are built-in current session-context
implementations in nhibernate :

Call
thread_static
Web

if I do <property name="current_session_context_class">Call</
property> , I still get the same exception.... What should I do ?

On 21 Apr, 13:32, Ken Egozi <egoz...@gmail.com> wrote:
> is "thread" a class?
>
> if not, you should either locate or implement a class, that can supply a
> current context based on thread.
>

graphicsxp

unread,
Apr 21, 2009, 8:55:01 AM4/21/09
to nhusers
Basically I'm trying to share the same session across all my DAO's by
using GetCurrentSession of the SessionFactory object.

It's a console application, so what should I do to get this to work ??
> > Ken Egozi.http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue...

Gustavo Ringel

unread,
Apr 21, 2009, 9:09:27 AM4/21/09
to nhu...@googlegroups.com
Take a look on uNHAddins sessionEasier.

graphicsxp

unread,
Apr 21, 2009, 9:35:39 AM4/21/09
to nhusers
What do I use to open the downloaded file ? There's no file
extension...

Anyway, I thought NH would provide the necessary context to share my
session across dao's, am I wrong ?

On 21 Apr, 14:09, Gustavo Ringel <gustavo.rin...@gmail.com> wrote:
> Take a look on uNHAddins sessionEasier.
>

graphicsxp

unread,
Apr 21, 2009, 9:43:47 AM4/21/09
to nhusers
Ha actually I've changed my property to :

<property name="current_session_context_class">thread_static</
property>

Now I get a different error :

No session bound to the current context

I guess there's still something wrong then. But I feel I've made some
progress, do you know what's missing ?

graphicsxp

unread,
Apr 21, 2009, 9:49:57 AM4/21/09
to nhusers
I keep replying to myself... sorry :p

CurrentSessionContext.Bind() was the missing link ! I'ts working
now..

Could someone confirm that thread_static is the correct context class
I should use ? Actually I've lied when saying I was using a console
app, I'm using a WCF service in fact. Is it still ok to use this
context class ?

Thanks

Riderman Sousa

unread,
Jun 15, 2013, 10:41:18 AM6/15/13
to nhu...@googlegroups.com
graphicsxp I'm having the same problem. You could solve?
Reply all
Reply to author
Forward
0 new messages