-->
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.  [ 8 posts ] 
Author Message
 Post subject: Multiple connection strings
PostPosted: Fri Jan 13, 2006 12:00 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
I'm working on a project where we have many companies as customers.
At the moment we have one database for all companies, but we are consider to use one database for each company instead.
At the same time we want to use the same release (the same assemblies) to all companies. And then decide connection string depending on what company it is.

How would this work with NHibernate? Would we have to have one SessionFactory for each company?

/Carl


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 14, 2006 6:34 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
If you launch a separate application instance for each company, then you only need one session factory for that company's database in the application. You can pass the connection string and other properties manually to the Configuration object.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 14, 2006 1:56 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Forgot to say that it is a web application. Is it possible to launch separate instances of a web application without having multiple copies of the assemblies?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 14, 2006 2:02 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
I should also say that its a ASP.NET 2.0 project.


Top
 Profile  
 
 Post subject: Re: Multiple connection strings
PostPosted: Mon Jan 16, 2006 1:09 pm 
Regular
Regular

Joined: Mon May 16, 2005 2:15 pm
Posts: 59
_carl_ wrote:
How would this work with NHibernate? Would we have to have one SessionFactory for each company?

/Carl


No. If the schema is the same for each database then you can still use a single session factory. When you ask the session factory for a session you can pass in the connection string of the db that you want it to talk to.

BOb


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 2:47 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Thanks Bob! Didn't know of that.

But couldn't there be trouble with caching when doing this? Like if some object in one of the companies databases has the same ID as an object in another companies database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 7:12 pm 
Regular
Regular

Joined: Mon May 16, 2005 2:15 pm
Posts: 59
_carl_ wrote:
Thanks Bob! Didn't know of that.

But couldn't there be trouble with caching when doing this? Like if some object in one of the companies databases has the same ID as an object in another companies database.


Only if you are using a second level cache.

BOb


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 9:42 am 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
Thanks again Bob!


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