Hi Max,
thank you for hinting to the generated-class meta attribute! It works fine as long as the mapping files do not contain any subclass relationships.
A mapping like the following example causes trouble:
Code:
<hibernate-mapping>
<class name="package.EntityName" table="A_TABLE">
<meta attribute="generated-class">package.EntityNameBase</meta>
...
<discriminator column="DISCR" type="string" length="1"/>
<!-- Subclasses -->
<subclass name="package.EntityNameSub1" discriminator-value="i">
<meta attribute="generated-class">package.EntityNameSub1Base</meta>
...
</subclass>
<subclass name="package.EntityNameSub2" discriminator-value="i">
<meta attribute="generated-class">package.EntityNameSub2Base</meta>
...
</subclass>
</class>
</hibernate-mapping>
The Class EntityNameBase is created correctly, but the subclasses are not created as files EntityNameSub1Base.java and EntityNameSub2Base.java. The contents of both subclasses appear to share the same physical file instead, and its file name is weird and contains parts of the package declarations. I hope you get what I mean; I can provide screenshots (for example) if it helps.
But we have another issue with the generated-class meta attribute with regard to inheritance and the manual creation of entity subclasses which contain additional methods. In the above example, we would like the following classes and inheritance relationships to be created by the generator:
EntityNameBase
EntityNameSub1Base extends EntityName (NOT extends EntityNameBase)
EntityNameSub2Base extends EntityName (NOT extends EntityNameBase)
where EntityName is the manually created subclass of EntityNameBase, i.e.:
EntityName extends EntityNameBase
EntityNameSub1 extends EntityNameSub1Base
EntityNameSub2 extends EntityNameSub2Base
If the generator creates "extends EntityNameBase" instead of "extends EntityName", the inheritance hierarchy is destroyed in the manually created subclasses (those without the Base name suffix). That means, EntityName would not be a superclass of EntityNameSub1 and EntityNameSub2.
I hope you get the idea although English is not my native language :-)
Regards,
Rico Starke