Hi,
the problem is, that i want to use my hibernate-pojos as base-classes (eg. mydomain.model.PersonBase) and extend them with classes like mydomain.model.Person for implementing specific issues.
Hibernate-Mapping
Code:
<hibernate-mapping>
<class name="Person">
<meta attribute="generated-class">mydomain.model.PersonBase</meta>
<id name="id" type="int">
<generator class="native"></generator>
</id>
<property name="name" type="string"></property>
</class>
</hibernate-mapping>
Ant-TaskCode:
<target name="hibernate-pojos" >
<hibernatetool destdir="${src}">
<configuration configurationfile="src/hibernate/hibernate.cfg.xml"/>
<hbm2java/>
</hibernatetool>
</target>
--> this outputs mydomain/model/PersonBase.java
Up to now everything is fine.
Now I want to generate the sublass Person from following template PojoSubclass.ftl.
TemplateCode:
${pojo.getPackageDeclaration()};
public class ${pojo.getShortName()} extends ${pojo.getDeclarationName()}
implements java.io.Serializable {
/** default constructor */
public ${pojo.getShortName()}() {
}
}
...with Ant-Task
Code:
<target name="hibernate-subclass-pojos" >
<hibernatetool destdir="${src}">
<configuration configurationfile="src/hibernate/hibernate.cfg.xml"/>
<hbmtemplate
filepattern="{package-name}/{class-name}.java"
template="PojoSubclass.ftl"
/>
</hibernatetool>
</target>
Now I have the problem, that the extended class will be named as the superclass (PersonBase) and overwrites it. So i need an expression in filepattern which represents "Person" and not "PersonBase" (like {class-name} does).
Greets Patrick