-->
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.  [ 2 posts ] 
Author Message
 Post subject: Pattern for deep OO inheritance
PostPosted: Tue Sep 05, 2006 7:29 pm 
Newbie

Joined: Tue Sep 05, 2006 7:00 pm
Posts: 1
Location: California
I'm looking how to implement 'table-per-subclass' with greater than 2 inheritance. E.g. (C# syntax)

classA{}
classB : ClassA{}
classC : ClassB{}

I've tried something like the following below: (Nested <joined-subclass>
But am having issues with inserts etc. (I'm using SQ 2000 and C#)
A sample app, (preferably C#) would be great!

<class name="MyClass.ClassA, MyNameSpace" table="ClassATable">
<id name="ClassAPrimId" column="ClassAPrimId">
<generator class="native" />
</id>
<property name="...."/>

<joined-subclass name="MyClass.MyClassB, MyNameSpace" table="ClassBTable">
<key column="FK_ClassB_PK_ClassA"/>
<property name="...."/>

<joined-subclass name="ZMyClass.MyClassC, MyNameSpace" table="ClassCTable">
<key column="FK_ClassC_PK_ClassB"/>
<property name="...."/>
</joined-subclass>
</joined-subclass>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 10:52 am 
Newbie

Joined: Fri Sep 15, 2006 10:29 am
Posts: 14
Hi,

The idea of having a table with a discriminator column is the following: each row of the table represents a single class, i.e. one row is either a classB, or a classC; but not both (sure you can do a type cast in your code, but now we are talking only about o/r mapping).
So, I think, the answer to your question is the following: specify all the discriminator values for the bottom levels (classC's and classB's that are not inherited by any of the classC's) in the classA <discriminator> tag. Then, classB's that ARE inherited by classC's should NOT have discriminator-value; instead, hibernate should automagically determine this from the underlying classC's. I haven't tested if this works. But, I think it's worth trying. If I were a hibernate developer, I would've done it this way.

Greetings,
Mitko


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

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.