-->
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: Using <subclass> and <joined-subclass>
PostPosted: Sun Dec 28, 2003 5:04 pm 
Newbie

Joined: Sun Nov 30, 2003 4:46 am
Posts: 17
Hi,

Im having a problem with using <subclass> and <joined-subclass>.
I have a base class Question (mapped onto table: Question) from which 2 classes extend namely, EssayQuestion and MCQ.
I have mapped MCQ onto the same table: Question. Thus I have used <subclass> for MCQ mapping.
For this I have specified a discriminator column in Question table and discriminator values in both Question and MCQ mappings.
I have mapped EssayQuestion onto a different table: EssayQuestion using the <joined-subclass> element. But in this case I have not specified any discriminator values. So my complete mapping
is of the form:

<class name="Question" table="Question"
discriminator-value="0"
>
<id name="id" column="id">
<generator class="identity"/>
</id>
<discriminator column="type" type="integer"/>

<subclass name="MCQ" discriminator-value="1">

......

</subclass>

<joined-subclass name="EssayQuestion"
table="EssayQuestion"
>
<key column="QuestionId_FK"/>
<property name="minWords" column="MinWords"/>
<property name="notes" column="Note"/>
</joined-subclass>

</class>

But when I build the session factory I get the following exception:

Quote:
Hibernate Exception = net.sf.hibernate.MappingException: Error parsing discriminator value: For input string: "EssayQuestion"


I have some questions regarding the whole scenario:

Is it because since I have specified a discriminator value in the base class Hibernate expects a discriminator value be provided for EssayQuestion even if it is specified in <joined-subclass> element?

Is it that if a class is mapped using table-per-class mapping all of its subclasses will be mapped that way with no possibility of its subclass to be mapped using table-per-subclass mapping?

The same question as above but the mapping is table-per-subclass?

Isnt there anyway I can map 2 subclasses of a class using "table-per-class" with one and "table-per-subclass" with the other?

Am I missing something here?

Thanx in advance for any advice and suggestions


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 7:01 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can't mix subclass and joined-subclass strategies for a hierarchy. You can try to use one-to-one mapping to substitute the joined-subclass.

_________________
Emmanuel


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.