I need to map a subclass based on a discriminator value, containing a collection and cannot find a way to do this.
I need to use method 9.1.4 from the hibernate docs to implment the inhertence, since the parent class has some info in a table, with a discriminator indicating the subclass type.
My problem is that I cannot map the set creditNotes below since this is not allowed by the DTD. However, I need to have this list available in my subclass. How do I go about this?
Hibernate version: 3
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain.tso">
<class name="Document" table="document" schema="public">
<id name="refId" type="integer">
<column name="tso_ref_id" />
<generator class="assigned" />
</id>
<discriminator column="tsotype" type="string" />
<property name="createdDate" type="timestamp">
<column name="created_date" length="8" />
</property>
<subclass name=Invoice" discriminator-value="INVOICE">
<join table="invoice">
<key column="id"/>
<property name="supplier" type="integer">
<column name="supplier" />
</property>
<set name="creditNotes" inverse="true">
<key>
<column name="invoice" />
</key>
<one-to-many class="CreditNote" />
</set>
</join>
</subclass>
</class>
Thanks