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