Hi all
I have a problem using inheritance with discriminator
here is the mapping
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>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="model.DataType" table="DATATYPE" discriminator-value="0">
<id name="dataTypeId" type="long" >
<column name="DATATYPEID" />
<generator class="sequence" >
<param name="sequence">DATATYPEID_sq</param>
</generator>
</id>
<discriminator column="DATATYPETYPEID" type="long"/>
<version name="beanVersion"
column="version_"
type="long" />
<property name="name" >
<column name="NAME" not-null="true" />
</property>
<property name="description">
<column name="DESCRIPTION" />
</property>
<property name="dataTypeId" insert="false" update="false">
<column name="DATATYPETYPEID" />
</property>
<subclass name="model.DataTypeEnumerated" discriminator-value="1">
<join table="DataTypeEnumerated">
<key column="DataTypeEnumeratedId" />
</join>
</subclass>
</class>
</hibernate-mapping>
Both DataType and DataTypeEnumerated are not abstract classes and DataTypeEnumeratedis derived from DataType. Saving objects works fine but when i load an object i get exception:
identifier of instance model.DataType altered from X to 0
What am I doing wrong?