-->
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: Discriminator for Intermediate-Level Abstract Class
PostPosted: Fri Jan 28, 2005 1:40 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
I've seen several posts on this subject, but no difinitive answer. I have a class structure like:

Code:
                AbstractObject*
           __________|__________
           |                    |
    ConcreteSubA          AbstractSubB*
                        ___________|____________
                        |                       |
                ConcreteSubC              ConcreteSubD

* Abstract Class

I'm using table-per-class-heirarchy and it works fine. But to pull it off, I've been mapping the intermediate abstract class (AbstractSubA*) with a discriminator value of "-1" or some other artificial value.

While this seems to work, I can't help but feel that there must be a better way to do it. I also worry that at some point in the future I'll run into a query that won't work properly as a result of my mapping.

Is this the best way to handle this situation?

Here's a sample of my mapping documents:

Mapping documents:
Code:
<class name="AbstractObjectA" table="obj">
    <id name="id" type="long" column="ID">
        <generator class="native"/>
    </id>
    <discriminator column="objType" type="integer"/>
    ...
    <subclass name="ConcreteSubA" discriminator-value="1">
        ...
    </subclass>
    <subclass name="AbstractSubB" discriminator-value="-1">
        ...
    </subclass>
    <subclass name="ConcreteSubC" discriminator-value="2">
        ...
    </subclass>
    <subclass name="ConcreteSubD" discriminator-value="3">
        ...
    </subclass>
</class>


Notice the discriminator value of -1 for the intermediary abstract class AbstractSubB. Is there a better way to handle this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 5:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
looks perfectly fine to me...


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.