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.  [ 1 post ] 
Author Message
 Post subject: Inheritance with Subclass and UnionSubclass
PostPosted: Mon Dec 21, 2009 9:05 am 
Newbie

Joined: Wed Oct 07, 2009 10:34 am
Posts: 2
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.