Questions tagged [isession]

47 questions
1
vote
1 answer

NHibernate 2.1.2 connection open upon factory.OpenSession()?

When I open a session with var session = factory.OpenSession(); and check session.Connection.State it is Open. The "Connection" is of type SqlConnection. This means that by creating the session the connection is automatically opened, which I…
Denis Biondic
  • 7,943
  • 5
  • 48
  • 79
1
vote
3 answers

How to get NHibernate ISession to cache entity not retrieved by primary key

My 'user' entity is almost always retrieved by username, rather than by its integer surrogate key. Because the username is not the primary key, this means that the ISession won't cache it and repeatedly hits the database to get the same data. Is…
David
  • 15,750
  • 22
  • 90
  • 150
1
vote
1 answer

Lazy initializing ISession using WebSessionContext/CurrentSessionContext

I'm starting a new project with NHibernate 3 and I'm trying to use the CurrentSessionContext API with WebSessionContext to manage my ISession object. In previous projects I always managed that myself so whenever I needed a ISession object I would…
tucaz
  • 6,524
  • 6
  • 37
  • 60
1
vote
1 answer

Within ActiveRecordMediator, should use Execute or CreateSession?

Suppose I'm going to do something that needs access to NHibernate's ISession. For example running a Sql query via ISQLQuery or running a LINQ-to-NHibernate via session.Linq(). I know there is 2 way to access ISession:…
Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
1
vote
2 answers

About NHibernate's ISession

In this question, the user asks the better way to close sessions because he was having some errors. The most voted answer is Ayende's answer that says: You should always use session.Dispose(); The other are for very strange occurances Should I…
Pedro
  • 11,514
  • 5
  • 27
  • 40
1
vote
3 answers

NHibernate not persisting collections

I have a rather strange error with NHibernate. I am was having error with ISession been shared by across threads and got this resolved by supplying my own ADO.NET connection like: IDbConnection connection = new…
coder
1
vote
2 answers

ISession per Request (Only when necessary)

I'm developing an application (asp.net mvc) and I'm using ISession per request (in globa.asax I use Bind and Unbind in Begin_Request event and End_Request event). Everything works fine but sometimes (some requests) I don't need to use an ISession (a…
Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
1
vote
1 answer

NInject, NHIbernate and ISession in request scope

I'm basically using an example which I've seen in many places but I'm not convinced it's working properly. So, I have the following: public class NHibernateHelper { private readonly string _connectionString; private ISessionFactory…
Big D
  • 155
  • 1
  • 3
  • 10
1
vote
1 answer

Setting nhibernate property-ref on one-to-many to property other than primary key fails

I am receiving this exception ONLY when I set the property-ref in my xml file. Initializing[Domain.Entities.R#12345]-failed to lazily initialize a collection of role: Domain.Entities.R.LP, no session or session was…
ben
  • 21
  • 3
1
vote
2 answers

Nhibernate in asp,net ISession help

We're using nhibernate in and asp.net MVC application. We are implementing the Session per Request pattern, via a httpModule. It looks pretty straight forward, but when we run with NHibernate Profiler, it clearly shows that the sessions are never…
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97
1
vote
1 answer

NHibernate Override ISession for Faking the Database during testing

I am working on a project that has over 2000 integration tests that full circles the database. I want to speed up the process so I thought why not fake the database. We are using Fluent NHibernate as our ORM which is probably why I am having such…
colemn615
  • 151
  • 1
  • 3
0
votes
1 answer

should we use our own Unit of work on top of Nhibernate ISession

I just start learning castle windsor. Have a quesiton about if I should add another unit of work on top of Nhibernate ISession. I found this on windsor…
qinking126
  • 11,385
  • 25
  • 74
  • 124
0
votes
2 answers

Stumped: Custom NHibernate Session management gives "Specified cast is not valid" exception (C#)

I am trying to implement some proper NHibernate session management in my console application, but running into some very weird problems. One moment everything seems to be working fine, but randomly, all of a sudden it starts throwing an "Specified…
Fedor Alexander Steeman
  • 1,561
  • 3
  • 23
  • 47
0
votes
1 answer

NHibernate 3, HttpModule and Errors

BACKGROUND: Creating the start of a web app with NH3 using HttpModule to manage the creation/commit/rollback of the transaction and session. In a scenario where an error occurs, i would like to return a simple message back to the user, but rollback…
TheITGuy
  • 722
  • 4
  • 15
0
votes
1 answer

How to add "or" statement in ISession.QueryOver?

I have a question: Is there a way to add "or" statement in ISession.QueryOver ? Consider I have these values: val1 = 0; val2=0; and my query: .Where(Restrictions.Eq(Projections.Property()=>obj1.val1),val1) //Or statement should comes to…
HAZAN
  • 61
  • 6