Here is my attempt. The error I get is "Found shared references to a collection: Short.choices" at run time. I basically need some way to override the definition of the List choices.
Code:
<hibernate-mapping>
<class name="Question" table="QUESTION" discriminator-value="null"
dynamic-update="true" polymorphism="explicit">
<!-- Discriminator -->
<discriminator column="QUESTION_TYPE" type="character" not-null="true"/>
<!-- Base class -->
<property name="text" column="LONG_TEXT" not-null="true"/>
<!-- Subclass QuestionLong -->
<subclass name="Long" discriminator-value="L">
<property name="maxLength" column="MAX_RESPONSE_LENGTH"/>
</subclass>
<!-- Subclass QuestionShort -->
<subclass name="Short" discriminator-value="S">
<list name="choices" lazy="false" table="CHOICE" outer-join="true" cascade="all">
<key>
<column name="QUESTION_NUMBER"/>
</key>
<index column="CHOICE_NUMBER"/>
<composite-element class="Choice">
<property name="choiceText" /> </composite-element>
</list>
<!-- Subclass QuestionWithAnswer -->
<subclass name="QuestionWithAnswer" discriminator-value="A">
<list name="choices" lazy="false" table="CHOICE" outer-join="true" cascade="all">
<key>
<column name="QUESTION_NUMBER"/>
</key>
<index column="CHOICE_NUMBER"/>
<composite-element class="ChoiceWithAnswer">
<property name="choiceText" /> <property name="correct" column="CORRECT"/>
</composite-element>
</list>
</subclass>
</subclass>
</class>
</hibernate-mapping>