We migrated .hbm.xml mappings to annotations (so we could use an annotation processor) and also encountered this issue in a hierarchy with subclasses having all their properties in <join table>s, similar to the following:
<class name="ParentXML" table="parent_xml" discriminator-value="PARENT">
<id name="id" type="string" length="36"/>
<discriminator column="dtype"/>
</class>
<subclass name="SubXML" extends="ParentXML" discriminator-value="SUB">
<join table="sub_xml">
<key column="id"/>
<!-- subclass properties -->
</join>
</subclass>
<subclass name="SubSubXML" extends="SubXML" discriminator-value="SUB-SUB">
<join table="sub_sub_xml">
<key column="id"/>
<!-- subclass properties -->
</join>
</subclass>
We changed it to a joined subclass hierarchy with discriminator and it resulted in the same schema being generated.
Using the session API and programmatically generated IDs we can persist but get the exception when querying subclasses with a subclass.(Another difference is that lazy-loaded associations to the parent class now return proxies of the parent class when they returned the real class before, but that is another issue)
The attached maven project contains both xml and annotated hierarchies and a test class that triggers the exception.
|