Hello, i have a kind of strategical problem with the following class hierarchy
Code:
[NHibernate.Mapping.Attributes.Class(Abstract=true)]
abstract class AloaObject
- Id (integer)
[NHibernate.Mapping.Attributes.UnionSubclass(Abstract = true, Extends = "AloaObject", ExtendsType = typeof(AloaObject))]
abstract class AloaSpatialObject : AloaObject
* Position (Coordinate)
[NHibernate.Mapping.Attributes.UnionSubclass(Extends = "AloaSpatialObject", ExtendsType = typeof(AloaSpatialObject))]
class Waypoint : AloaSpatialObject
* Time (DateTime)
[NHibernate.Mapping.Attributes.Discriminator(Column="SubClass", Type="string", TypeType=typeof(string))]
* SubClassType (string)
[NHibernate.Mapping.Attributes.Subclass(Extends = "Waypoint", ExtendsType = typeof(Waypoint), DiscriminatorValue = "CollectionWaypoint")]
class CollectionWaypoint : Waypoint
* AmountOfGarbage (double)
When i run the hibernate setup routine for doing the mapping and creating the database
i get the following error:
No discriminator found for AloaObjects.Domain.Logistic.Waypoints.CollectionWaypoint. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses.I think it is because i am missing the Discriminator Value of the Waypoint class which is part
of the subclass mapping with CollectionWaypoint. But since Waypoint is also part of the UnionSubclass mapping with AloaSpatialObject, it cannot contain a Discriminator value...
How can ONE class take part in TWO different inheritance patterns of hibernate?
The point is that many other classes inherit from AloaSpatialObject and should have that data in their own tables (UnionSubclass) but the various implementations of the Waypoint (such as CollectionWaypoint) should be in one table (Subclass).
Thanks for any advice!