Hi!
I've got mapping like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class discriminator-value="0" name="Testee" table="testee">
<id column="id" name="id" type="integer">
<generator class="increment"/>
</id>
<discriminator column="type_id"/>
<property column="create_date" name="createDate" type="date"/>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<subclass extends="Testee" name="Testee2" discriminator-value="1">
<property column="email" name="email" type="string"/>
</subclass>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Attempt" table="attempts">
<id column="id" name="id" type="integer">
<generator class="increment"/>
</id>
<many-to-one class="Testee" column="testee_id" name="testee"/>
</class>
</hibernate-mapping>
So, when i'm trying to get Testee2 (according to discriminator) object from Attempt object, hiberhate fetches Testee object that I can't cast to Testee2.
How can I save inheritance mapping and fetch object of correct class?