Hibernate version: 2.1
Mapping documents:
Base.hbm.xml
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="eg.Base" table="BASE">
<id name="id" type="java.lang.Integer" unsaved-value="null">
<meta attribute="scope-set">protected</meta>
<column name="UID" not-null="true"/>
<generator class="native"/>
</id>
</class>
</hibernate-mapping>
SubclassOne.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<joined-subclass name="eg.SubclassOne" table="SUB_ONE" extends="eg.Base">
<key column="UID" />
</joined-subclass>
</hibernate-mapping>
Ant task and target:Code:
<taskdef name="hbm2java" classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask" classpathref="classpath" />
<target name="codegen">
<hbm2java output="${src.dir}">
<fileset dir="${src.dir}">
<include name="**/Base.hbm.xml" />
</fileset>
<fileset dir="${src.dir}">
<include name="**/SubclassOne.hbm.xml" />
<include name="**/*.hbm.xml" />
</fileset>
</hbm2java>
</target>
I know that section 5.4 of the manual says, "Use of this feature makes the ordering of the mapping documents important!" And I've also read a previous reply to the same question and have implemented the fix as specified in that messages reply, but I'm still having problems. Here is the output from my Ant task:
Code:
Buildfile: C:\eclipse3\workspace\Hibernate\build.xml
codegen:
[hbm2java] Processing 3 files.
[hbm2java] Building hibernate objects
[hbm2java] 09:03:54,340 INFO Generator:95 - Generating 1 in C:\eclipse3\workspace\Hibernate\src
[hbm2java] 09:03:54,387 INFO Generator:95 - Generating 1 in C:\eclipse3\workspace\Hibernate\src
[hbm2java] net.sf.hibernate.MappingException: Cannot extend unmapped class eg.Base
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.handleClass(CodeGenerator.java:147)
[hbm2java] at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:118)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.java:145)
[hbm2java] at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java:95)
[hbm2java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[hbm2java] at org.apache.tools.ant.Task.perform(Task.java:364)
[hbm2java] at org.apache.tools.ant.Target.execute(Target.java:301)
[hbm2java] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[hbm2java] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[hbm2java] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[hbm2java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:377)
[hbm2java] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)
BUILD SUCCESSFUL
Total time: 1 second
The Base.class file is generated without any problems, but it fails to generate the SubclassOne.class file. Any suggestions?
Thanks,
JB