-->
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: help with hierarchy mapping?
PostPosted: Thu Aug 10, 2006 8:36 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Hi,
I would like to perform the following mapping, can someone help?
I have an interface, from which 2 abstract classes are derived:
BASE --> AB1, AB2
There is a very big difference between the fields of AB1 and AB2, so just for them, I would like to use the table per-subclass approach ('joined-subclass').
However, all classes derived from AB1, AB2 do not add any members, I would like to keep the entire AB1 hierarchy in a single table. Same goes for AB2.
BUT: I cannot define a "discriminator column" for AB1, AB2 because they are declared as 'joined-subclass'!! Also, I cannot use the "table per subclass using disc." because it does not accept the 'many-to-one' property for some reason...

Can someone help me understand how I am supposed to map this???


Hibernate version:
3.1
Mapping documents:
For the base interface:
Code:
    <class name="Base" table="BASE">
        <id name="id" column="BASE_ID">
            <generator class="native"/>
        </id>
    </class>

For AB1:
Code:
    <joined-subclass name="Ab1" extends="Base" table="AB1">
        <key column="AB_ID"/>
        <discriminator column="class" type="string"/> <-------- ERROR
        <many-to-one name="server" column="SRV_ID" cascade="all" class="Server"/>
        <property name="name" column="NAME" access="field"/>
    </joined-subclass>

For AB2:
Code:
    <joined-subclass name="Ab2" extends="Base" table="AB2">
        <key column="AB_ID"/>
        <discriminator column="class" type="string"/> <-------- ERROR
        <many-to-one name="site" column="SITE_ID" cascade="all" class="Site"/>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


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.