Forget it. For better or for worse, we are not using polymorphism in the "standard" sense -- we are only supporting entity subclasses to allow our customers to replace our entities with their extensions. This replacement is not provided by <class polymorphism="true">, so apparently our efforts to provide a mechanism where entity type replacement occurs transparently was not a waste of time.
Let me put it this way, using the Cat example. Say our product defines a basic Cat entity. Out-of-the-box, this Cat entity is not all that useful. Our customers are very different -- one may be a veterinary clinic, one a pet store, one a research laboratory. They each want to track different additional information about Cats, so they subclass the Cat entity and add properties. All of their Cats are of their subclass. Yet, we provide basic functionality in our product to query and manage Cats, and this source code needs to deal with Cat queries returning the customer's subclass. Standard display and reporting will of course not show the subclass's additional properties, but it will still work. The customer will of course add additional data forms and queries that know about their subclass and do something with the additional properties. Now add to this the possibility that there are three or more "layers" of customization -- we may sell our product to a VAR, who extends our entities with subclasses, and then sells it to customers who then extend it further with their subclasses.
Of course, using subclasses in this way prevents any given customer from using subclasses for polymorphism. A big loss? Well, we are converting our application from a 2-tiered system that used ADO.NET untyped DataSets and the "Table Module" pattern to one with true entity objects and NHibernate. OO-design is not warmly embraced at my company, so adopting ORM was done reluctantly and is still questioned. Using different classes for data stored in the same table by use of discriminator columns in the NHibernate mapping would be considered unnecessary complexity.
|