Mapping entities across multiple DBs on different servers w/o DB link

118 views
Skip to first unread message

Xoum

unread,
Mar 10, 2011, 4:40:53 AM3/10/11
to nhusers
Hello everyone,

Looking to implement something loosely similar to what is described in
this Q&A post: http://dba.stackexchange.com/questions/728/multi-database-object-oriented-proxy,
I'm evaluating different technologies to get the work done without
spending months to implement something from scratch.

Being not very familiar with NHibernate, I had to do some research and
found a bunch of (possibly outdated) articles and forum posts on this
subject, some seeming contradictory, and many hesitating, but could
not get a definitive answer to that question:

Using the latest version of NHibernate (and possibly some plugins), is
that possible to map entities across multiple databases on different
servers *without DB link*?


Thank you and best regards

Jason Meckley

unread,
Mar 10, 2011, 10:00:54 AM3/10/11
to nhu...@googlegroups.com
are you talking about storing a single entity across multiple databases, or sharding the database to store the same type of data across multiple databases?
NH has an extension for sharding, but I'm not aware of the state of this projects. It's part of NH contrib, iirc.

if you are talking about storing a single entity across multiple databases, the answer is not cleanly. you might be able to do something with custom user types and/or event listeners to hydrate the object, but that would be a mess to maintain.

A different approach is to transfer the data from one db to another using an ETL process. similar to replication, but only transferring the data required by the other database. you end up with 1 writable database and many read databases. then you map the domain to a single database.

Another option is to determine why there are multiple databases. if they represent different types of data/objects then explicitly express this in the domain. for example CustomerWithAddress is a different entity than CustomerOrder. If you need information from both, then query each database individually and build up a projection in code.
var x = session1.get<CustomerWithAddress>(id);
var y = session2.get<CustomerOrder>(id);
return merge(x, y);
Reply all
Reply to author
Forward
0 new messages