-->
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: Sharing database connections across ISession instances
PostPosted: Mon Jan 30, 2006 5:22 pm 
Beginner
Beginner

Joined: Sat Apr 17, 2004 1:11 am
Posts: 36
There were some discussions on the old forum about this but I can't find them now. I remember that it was frowned upon to create multiple ISession instances that used the same database connection but I don't remember exactly why. If you manage your own connections, as I do, then could I create a single connection and use that in more than one ISession? This app will not use multiple threads so there wouldn't be more than one chunk of code attempting to do anything with the connection at the same time.

Thx...

benster


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:35 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You may reuse connections, just note that NHibernate disables second-level cache when using a user-supplied connection. This can be avoided if you write your own IConnectionProvider.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:24 pm 
Beginner
Beginner

Joined: Sat Apr 17, 2004 1:11 am
Posts: 36
Thanx Sergey - my question really is around having multiple ISession instances using a single connection at once. I understand that I can reuse them but I wondered if I can have a single connection that's used by more than one long-running ISession at once.

Specifically, what technical reasons are there in NH that would preclude this? We won't be spawning threads for these sessions but the app is a WinForms app that would benefit from having multiple long-running sessions for different modules in the app. If these could use the same connection (since they will not be spawning transactions at the same time) then that would be a good thing.

Any thoughts?

benster


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.