-->
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.  [ 9 posts ] 
Author Message
 Post subject: How do I specify multiple databases?
PostPosted: Wed May 25, 2005 7:15 pm 
We have objects spanning over several databases, I can't seem to find documentation on how to setup more than one connection and map objects to these alternate connections.


Top
  
 
 Post subject:
PostPosted: Thu May 26, 2005 1:34 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
Not sure if I'm understanding your question fully, but if you are talking about an object that persists data across two separate databases, this is a Hibernate 3 feature and I doubt it has been implented in NHibernate.

-devon


Top
 Profile  
 
 Post subject: One database per SessionFactory
PostPosted: Thu May 26, 2005 3:41 am 
Newbie

Joined: Wed May 11, 2005 9:34 pm
Posts: 9
Each SessionFactory can only handle one database. You can create several SessionFactories though (one for each DB), but there will be no relationship between them.

Regards,
Lars Arne Brekken


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 5:25 pm 
Seems like a stupid question, but how do I build diffrent session factories with hibernate.cfg.xml or web.config ?


Top
  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 4:11 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Depends on how you get your Configuration instance. For ex you could have some function that opens the session - and you need a session per database. So you call your function with some parameter that would make difference:

seesion1 = OpenSession("Path1")
session2 = OpenSession("Path2")


Then in the OpenSession function you feed this path to NHibernate.Cfg.Configuration:

NHibernate.Cfg.Configuration.Configure("Path to file")

Something like this...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:34 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 11:21 am
Posts: 23
Location: erie, pa
I have an app using NHibernate calling multiple databases on the same MSSQL server. I set up all my mapping files where the table names are denoted as databaseA..table1, databaseB..table5, etc.. Then my single session factory treats all the databases as a single database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:52 pm 
Does this allow you to have relationships between tables across those databases?

jimbolla wrote:
I have an app using NHibernate calling multiple databases on the same MSSQL server. I set up all my mapping files where the table names are denoted as databaseA..table1, databaseB..table5, etc.. Then my single session factory treats all the databases as a single database.


Top
  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 12:30 pm 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
You sure can, as long as you fully qualify each table in the mapping file (ie. Northwind.dbo.Products).

This also works if you are using databases from two different SQL Servers, as long as you create a linked-server connection between the two (through enterprise manager). But then you need to qualify the table names with the server name as well (ie. MySQLServer2.Northwind.dbo.Products).

I've used this to string together several different databases on different servers. It may not be the most performant method, but it is the most structured. Make sure you configure DTC on each server correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 8:44 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:50 pm
Posts: 22
Thanks tylord!

This should get me around one issue I was having with nhibernate and understanding how I can link multiple databases together.

I was previously creating views in one database that showed tables from another database but I seriously did not like the though of doing this, especially when it came to running updates.


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