-->
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.  [ 3 posts ] 
Author Message
 Post subject: Linq and NHibernateContext class
PostPosted: Wed Dec 26, 2007 5:37 pm 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Hibernate version:2.0 - alpha???

I am experimenting linq library and noticed that the NHibernateContext class has only one constructor. I have to pass an ISession object to it that will be
disposed inside the dispose of NHibernateContext class.

My question is.Should NHibernateContext dispose method disposes the session? I already have the code to dispose the session after I finish using it.

Note: I'm keeping and getting my sessions with thread context and it is
messing with it after I use linq queries.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 28, 2007 8:29 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
I'll explain why this question is here. I sent it to directly to Ayende and he asked me to put it here. I thought he would like to answer it here because many people could read it. Now I think he asked that because it's a dumb question and anyone could answer me.

For who is interested in the subject I'll explain it better. I got Ayende's library to translate Linq to NHibernate. It's not complete yet but I wanted to do some tests. There is a class called NHibernateContext and the constructor expects an ISession object as parameter. Here is the Dispose method of this class.

public virtual void Dispose()
{
if ( session != null )
{
session.Dispose();
session = null;
}
}

I already have a method to dispose my session and I believe everybody has.
I thought I could create a new session only to use with linq but I'm not sure it's gonna work. Also I don't want to evict or pass objects from one session to another.

That's it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 8:52 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
OK. I found a bug in my code. I've declared a static variable that was holding the session and this was messing with everything.


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