I have an interesting situation that I'm trying to solve with inheritance but the documentation doesn't seem to support what I'm trying to do.
I'm simplifying, but the basic situation is that our system has two database schemas. One (the "site" schema) is used at each individual installation of the program; there are many of them. The other (the "gateway" schema) is an aggregation schema; there is a single instance, and data from all the sites is aggregated into the gateway for global visibility, etc.
Many of the tables that exist on the site also exist on the gateway, but the gateway tables typically have some additional data elements that the sites do not have. An example:
At the site, the Item entity contains ItemId, ItemDescription, and something like 20 other properties. The gateway version of Item (call it "GatewayItem") includes all of the site's Item properties, plus some other ones, such as UnitPrice. The table is called "Item" in both schemas.
From an OO perspective, it makes sense for GatewayItem to derive from Item and simply define the additional properties. However, the inheritance strategies I see in the documentation seem to apply to separate entities within the same database, whereas in my situation I have two tables with the same name in different databases, one of which contains extra columns.
The intention is to invoke NHibernate with actual types; when I want to save a GatewayItem, I will call session.Save and pass a GatewayItem. I am simply trying to avoid having two classes with the same properties and mappings, and to allow our service layer to accept GatewayItem in methods that take an Item.
Is what I want to do even possible? I have the mapping written for Item, but I don't know where to even start for GatewayItem. I am trying to figure it out in parallel with this posting, in the hopes that someone here can save me some time. Apologies if I'm missing something obvious!
Thank you,
Mike
|